urllib2, proxies, and pac files on OS X

Mani Ghasemlou mani at tungle.com
Mon Mar 30 11:00:58 EDT 2009


Hi all,

urllib2 correctly detects proxies as configured in my preferences pane
on OS X 10.5:

Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.ProxyHandler().proxies
{'http': 'http://openproxy.in.tungle.com:8080'}
>>>

However, when configuring a proxy via PAC file, this does not seem to
be the case:

Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.ProxyHandler().proxies
{}
>>>

Is there any way to obtain (and parse using something like pacparser)
the PAC file via urllib2 (or some other standard python library), or
is this something I need to tackle using Cocoa (in my case PyObjC)?

Thanks a lot!

Mani



More information about the Python-list mailing list