How do I use proxies with httplib?

Jeffrey Kunce KUNCEJ at mail.conservation.state.mo.us
Wed Apr 21 16:55:11 EDT 1999


>I want to use httplib through a proxy server and I can't seem to get
>it to work.  Someone in this group suggested setting an environment
>variable, like:
>
>SET http_proxy="12.189.130.200:80"

I don't know that that will work for httplib.
I know it *does* work with urllib. 
An example from memory (not tested):

import os, urllib
os.environ['http_proxy']="http://12.189.130.200:80"
f = urllib.urlopen('http://www.python.org')
data = f.read()

  --Jeff




More information about the Python-list mailing list