FTP with urllib2 behind a proxy

John J. Lee jjl at pobox.com
Thu Aug 14 07:54:59 EDT 2003


pythonguy at Hotpop.com (Anand Pillai) writes:

> jjl at pobox.com (John J. Lee) wrote in message news:<87wudhoh5c.fsf at pobox.com>...
> > pythonguy at Hotpop.com (Anand Pillai) writes:
> The code obviously caters to the bottom-line, in case
> the programmer does not want to worry about environment
> variables, would like to install the handlers himself
> and his proxy needs authentication.

Sure, I understand that.  I was just elaborating, no criticism was
intended!

It seems people are frightened to use urllib2 (perhaps partly because
the documentation has lots of sections -- though they're all very
short), so I like to point out that most of the time it's just a
matter of:

import urllib2
urllib2.urlopen("http://example.com/")


And most of the rest of the time, the only complications above that
are passing a Request instead of a URL (for adding headers and passing
around requests as first-class objects), and building your own opener
with build_opener (for choosing what features you want and don't want,
like authentication -- and adding your own features, of course).


John




More information about the Python-list mailing list