Autodiscovery of proxy settings from a python script

Andy Robinson andy at reportlab.com
Fri Mar 8 16:11:18 EST 2002


Thanks to several people.  I am once again stunned by how
good the Python standard library is.  I spent an afternoon
surfing and assumed I'd have to write code, but urllib does
most of what I want by default :-)

Idiot's guide to proxy discovery and use:

1. if hacking at home, get a working proxy server.  I found this
which compiled fine and "sort of" works - dislikes GIFs
but can receive plain pages:
  http://www.codeguru.com/internet/http_proxy.shtml


2.  Thereafter, set the proxy in IE and you can do this:
>>> urllib.getproxies()
{'ftp': 'ftp://matterhorn:5060', 'http': 'http://matterhorn:5060'}
>>>

3. Thereafter, calls to urllib.urlopen(myURL) seem to go through
the proxy by default.

- Andy





More information about the Python-list mailing list