urllib3.ProxyManager 给出身份验证错误 [英] urllib3.ProxyManager is giving authentication error

查看:63
本文介绍了urllib3.ProxyManager 给出身份验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 urllib3.ProxyManager 发送 https 请求.我的代码看起来像这样

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)

我收到以下错误 -

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')))

谢谢,亚特里克

推荐答案

我认为你需要在 ProxyManager 中设置 proxy_headers,而不是 headers:

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)

请参阅文档中的 urllib3.poolmanager.ProxyManager:https://urllib3.readthedocs.io/en/latest/reference/

See urllib3.poolmanager.ProxyManager in the docs: https://urllib3.readthedocs.io/en/latest/reference/

这篇关于urllib3.ProxyManager 给出身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆