Ben Ben - 1 month ago 12x
Python Question

How to set proxy while using urllib3.PoolManager in python

I am currently using connection pool provided by urllib3 in python like the following,

pool = urllib3.PoolManager(maxsize = 10)
resp = pool.request('GET', '')
content =

However, I don't know how to set proxy while using this connection pool. I tried to set proxy in the 'request' like
pool.request('GET', '', proxies={'http': ''}
but it didn't work.

Can someone tell me how to set the proxy while using connection pool



There is an example for how to use a proxy with urllib3 in the Advanced Usage section of the documentation. I adapted it to fit your example:

import urllib3
proxy = urllib3.ProxyManager('', maxsize=10)
resp = proxy.request('GET', '')
content =
# You don't actually need to release_conn() if you're reading the full response.
# This will be a harmless no-op:

The ProxyManager behaves the same way as a PoolManager would.