using httplib for authentication

Fuzzyman fuzzyman at gmail.com
Wed Aug 3 11:41:11 EDT 2005


James Stroud wrote:
> Hello All,
>
> I want to use python to download files from sites where authentication is
> required. The page appears to send a form with the login and pass by post. I
> would like to log in and keep this session open within python and
> download a number of files automatically. Could anyone kindly point me in the
> right direction? I have discovered httplib and read the documentation and
> looked at the examples, but they don't seem helpful for this.
>

Hello James,

httplib is built on top of the socket module - but is still a library
meant for doing fairly low level http operations. For fetching URLs,
urllib2 is probably the way to go. It handles GET and POST with ease.

If you think this will do the job then you could try reading the
urllib2 tutorial at :

http://www.voidspace.org.uk/python/articles.shtml#http

You might wnat to look at other extension modules too - ClientCookie
for handling cookies, ClientForm for automatically filling in the
forms, BeautifulSoup for parsing HTML pages....

All the Best,

Fuzzy
http://www.voidspace.org.uk/python

> James
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
> 
> http://www.jamesstroud.com/




More information about the Python-list mailing list