[Tutor] Cookies and authorization

Christian Wyglendowski Christian.Wyglendowski at greenville.edu
Thu Jun 23 21:56:04 CEST 2005


> -----Original Message-----
> Christian, 
> > Try subclassing urllib.FancyURLopener and overriding the
> > prompt_user_passwd() method.  That should get you what you need :-)
> Well, I used urllib.FancyURLopener, and can open and look at 
> the url, like this:
> import urllib
> opener2 = urllib.FancyURLopener({})
> f = 
> opener2.open("http://www.pythonchallenge.com/pc/return/romance.html")
> f.read()
> ..but to get at the cookies, I need to use urllib2.build_opener

Ah ha ... I should have been paying more attention :-)

> instead of urllib.FancyURLopener so that I can have access to
> urllib2.HTTPCookieProcessor, which does not seem to be an option in
> the regular urllib module?  Sorry if this seems like a dense question,
> I have little-to-no experience with cookies (and very little with
> urllib itself), so the examples sometimes leave me hanging!

It looks like the link that Kent suggested uses urllib2 and gives some
good examples of how to do authentication.  
> I'd appreciate any clarification you could give, or if you meant
> something else by your message?

I don't have much programming experience with cookies, so I don't have
much more to offer.  Good luck!


More information about the Tutor mailing list