httplib and Proxy

Fredrik Lundh fredrik at
Thu Nov 20 16:28:52 CET 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:


More information about the Python-list mailing list