Ben Ben - 1 year ago 259
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


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download