【问题标题】:urllib3.ProxyManager is giving authentication errorurllib3.ProxyManager 给出身份验证错误
【发布时间】:2019-09-27 09:21:18
【问题描述】:

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

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

谢谢, 亚特里克

【问题讨论】:

标签: python proxy urllib3


【解决方案1】:

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

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/

【讨论】:

    猜你喜欢
    • 2020-01-21
    • 1970-01-01
    • 2012-07-05
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-05
    相关资源
    最近更新 更多