问题
I am trying send a https request using urllib3.ProxyManager. My code looks something like this
default_headers = urllib3.util.make_headers(proxy_basic_auth='user:passwd')
http = urllib3.ProxyManager(proxyUrl, headers=default_headers, ca_certs=certifi.where())
http.request('GET', url)
I am getting below error -
MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='clinicaltrials.gov', port=443): Max retries exceeded with url: /ct2/results?term=Lilly&displayxml=true&count=5000 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))
Thanks, Yatrik
回答1:
I think you need to set proxy_headers, not headers in ProxyManager:
default_headers = urllib3.util.make_headers(proxy_basic_auth='user:passwd')
http = urllib3.ProxyManager(proxyUrl, proxy_headers=default_headers, ca_certs=certifi.where())
http.request('GET', url)
See urllib3.poolmanager.ProxyManager in the docs: https://urllib3.readthedocs.io/en/latest/reference/
来源:https://stackoverflow.com/questions/58131573/urllib3-proxymanager-is-giving-authentication-error