How to use Proxy PAC file for python urllib or request?

Kaymatrix picture Kaymatrix · Jul 21, 2015 · Viewed 9.7k times · Source

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

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

Answer

Carson Lam picture Carson Lam · May 22, 2017

I've created a pure-Python library called PyPAC which should do what you're looking for. It provides a subclass of requests.Session that includes honours PACs and includes PAC auto-discovery.