[Tutor] Web client in Python

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 28 May 2002 22:41:24 -0700 (PDT)


On Tue, 28 May 2002, Kevin Christy wrote:

> Dear folks:
>
> I visit a website frequently that requires a login each time I enter it.
> Typically, I log in, navigate to the search page, and input a search term.

Sounds like you're thinking of writing a web robot.  Interesting project!


It's very possible that the server sends off a cookie to your computer, so
that it can keep track of the login stuff.  The 'Cookie' module is pretty
good at keeping this information, and you might find it useful:

     http://python.org/doc/lib/module-Cookie.html

Another module that you might find useful is the httplib library, which
allows your Python to communicate to a server as if it were a web browser.

    http://python.org/doc/lib/module-httplib.html
    http://python.org/doc/lib/httplib-examples.html


With these two modules, I think it's possible to cook something up to
allow your program to work.



> Is there a way that you know of to "log" my session so that I can see what
> actually happens behind the scenes (in other words, what the browser and
> server are passing back and forth to each other)? That would help me
> automate the process. Thanks!

This one I'm not quite so sure about.


Good luck to you!