httplib and Proxy

Fredrik Lundh fredrik at pythonware.com
Thu Nov 20 10:28:52 EST 2003


Rolf Wester wrote:

> I want to fetch some web-pages via http. I know how to do this without a
> proxy server in between but unfortunately we can only access the
> internet via a proxy. I would be very appriciative if anybody could tell
> me how to do this.

use urllib, not httplib.

>>> import os, urllib
>>> os.environ["http_proxy"] = "http://proxyserver:3128"
>>> data = urllib.urlopen("http://server/page").read()

you can of course set the http_proxy environment variable before you start
Python.  on Windows, you can also use the standard "Internet Options"
dialogue to configure the proxy.

also see:

    http://www.python.org/doc/current/lib/module-urllib.html

</F>








More information about the Python-list mailing list