Python Scripts to logon to websites

Peter Hansen peter at
Wed Jan 11 14:02:04 EST 2006

BartlebyScrivener wrote:
> New to Python and Programming. Trying to make scripts that will open
> sites and automatically log me on.
> The following example is from the urllib2 module.
> What are "realm" and "host" in this example. probably provides more background 
than you want on that topic, but googling for "basic authentication" and 
maybe "realm" and/or "host" will find you other sites with less 
technically detailed material.  The first hit has a little summary 
amidst some Apache-specific detail.

> Does anyone have a simple example of a script that opens, say, gmail or
> some other commonly accessed site that requires a username and password
> so that I can see how one is made?

"realm" and "host" are associated with "basic authentication" and not 
all sites use that.  If the browser pops up a little dialog box of its 
own (i.e not some Javascript-triggered thing) and you have to enter your 
username and password there, that's probably a "basic auth" (or "digest 
auth") site.  If you fill that info into a form (as on you 
don't want any of that "realm/host" stuff.

I'll leave it to others more expert in this to provide a more directly 
useful answer.


More information about the Python-list mailing list