【问题标题】:Python requests with proxies 407 status code even though curl works即使 curl 工作,带有代理 407 状态代码的 Python 请求
【发布时间】:2014-09-24 18:26:08
【问题描述】:

以下 curl 有效:

curl -vx proxy.example.com:8010 -U user:pass http://example.com

并返回有效内容,响应码为 200。

但是,通过 python 请求库使用的相同凭据会产生 407 状态代码(身份验证错误)。查看日志后,看起来用户从未通过(未定义)。

url = "http://example.com"
proxies = {'http': 'http://proxy.example.com:8010'}
auth = HTTPProxyAuth("user", "pass")

resp = requests.get(url, proxies=proxies, auth=auth)

我正在使用请求库 2.3.0。

【问题讨论】:

标签: python proxy python-requests proxies


【解决方案1】:

最终,通过在 URL 中使用“https”而不是“http”来解决问题。

我只能推测为什么这是解决方案:可能是请求库的不同版本或一些错误?我将研究这些问题,看看为什么会这样。

【讨论】:

    猜你喜欢
    • 2023-01-29
    • 2015-11-09
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    • 2021-03-07
    相关资源
    最近更新 更多