[Tutor] password protection in httplib

Kent Johnson kent37 at tds.net
Fri Mar 3 15:35:54 CET 2006


Andre Engels wrote:
> 2006/3/3, Kent Johnson <kent37 at tds.net>:
> 
> 
>>Have you tried using a CookieManager as shown in the first example here:
>>http://docs.python.org/lib/cookielib-examples.html
>>
>>Once you set up your opener with a CookieJar the cookies should be
>>handled automatically - if a server sets a cookie it will be remembered
>>and returned back to the server on subsequent requests.
>>
>>This page has more examples though again IMO they are overly complex:
>>http://www.voidspace.org.uk/python/articles/cookielib.shtml
> 
> 
> I had looked at it yes, but I don't know how to combine the two
> handlers (the one for authentication and the one for cookies). Apart
> from that I hoped that because the program already has cookie handling
> programmed in, reusing that code might be less trouble than splitting
> the authenticated and the non-authenticated case everywhere.

The call to urllib2.build_opener() accepts multiple arguments, just list 
both handlers.

Kent



More information about the Tutor mailing list