How to use python urllib PAC PAC file or request?

How do I enable my proxy config file in HTTP libraries like urllib or requests.

pacfile = 'http://myintranet.com/proxies/ourproxies.pac'
proxy = urllib3.ProxyManager(????????????????)

      

+3


source to share


2 answers


There is currently no support for the PAC proxy file directly in urllib3 or requests. While support can in principle be added for PAC files with proxies as they are Javascript files that require interpretation, it is probably extremely difficult to provide broad support.



Basically you can use requests / urllib 3 to request a PAC Proxy file, then pipe it to something like Node.JS for interpretation, then parse the results in Python to pass urlib3 / requests, but nothing like that exists out of the box.

+5


source


I created a pure-Python library called PyPAC that should do what you are looking for. It provides a subclass requests.Session

that includes PAC awards and PAC auto-discovery.



+4


source







All Articles