【问题标题】:Python Requests library GET/POST gives ConnectionError: HTTPConnectionPool with proxy [closed]Python请求库GET / POST给出ConnectionError:带有代理的HTTPConnectionPool [关闭]
【发布时间】:2013-03-30 18:37:31
【问题描述】:

我正在使用 Python 库 Requests 为我公司的服务器软件编写 API 包装器。我正在 Windows 7 64 上使用 Python 2.7 编写测试脚本。我们使用代理连接到我的工作网络,我们将调用 IP x.x.x.x:8080。我的脚本如下:

import requests

ssHost = 'localhost'
ssPort = 3700
aci_Action = 'GetStatus'

aci_params = {'Action':aci_Action}
aci_RequestUrl = 'http://' + ssHost + ':' + str(ssPort)

aci_response = requests.get(aci_RequestUrl, params=aci_params)

print(aci_response.text)

这应该向http://localhost:3700/Action=GetStatus 发送一个GET 请求,当我在我的工作网络上时它工作正常。但是,当我回到家并且没有使用代理进行连接时,我会在运行脚本时得到以下信息:

ConnectionError: HTTPConnectionPool(host='x.x.x.x', port=8080): url 超出最大重试次数:http://localhost:3700/?Action=GetStatus (引起:[Errno 10060] 连接尝试 失败,因为连接方没有正确响应后 一段时间,或建立连接失败,因为已连接 主机没有响应)

我确定我已使用 Internet Explorer 中的设置关闭了代理,但我仍然收到此错误。问题是,错误显示的代理地址是我不再使用的旧地址。我试图弄清楚这个代理的设置位置。这里发生了一些我不明白的事情,如果有人能指出我在故障排除方面的正确方向,我将不胜感激。谢谢!

【问题讨论】:

    标签: python rest proxy python-requests


    【解决方案1】:

    仔细检查 Internet 选项中的代理设置,并检查环境变量 http_proxy 是否存在。

    【讨论】:

    • http_proxy 环境变量就是它。谢谢!
    猜你喜欢
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-09
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    相关资源
    最近更新 更多