【发布时间】:2013-01-15 23:29:25
【问题描述】:
我知道如何很好地使用requests,但由于某种原因,我没有成功让代理工作。我提出以下要求:
r = requests.get('http://whatismyip.com', proxies={'http': 'http://148.236.5.92:8080'})
我得到以下信息:
requests.exceptions.ConnectionError: [Errno 10060] A connection attempt failed b
ecause the connected party did not properly respond after a period of time, or e
stablished connection failed because connected host has failed to respond
但是,我知道代理可以工作,因为使用节点:
request.get({uri: 'http://www.whatismyip.com', proxy: 'http://148.236.5.92:8080'},
function (err, response, body) {var $ = cheerio.load(body); console.log($('#greenip').text());});
我得到以下(正确)响应:
148.236.5.92
此外,当我完全不同地尝试requests 请求时(例如,不在代理前面写http://),它只允许请求正常通过而无需通过代理或返回错误。
我在 Python 中做错了什么?
【问题讨论】:
标签: python node.js proxy python-requests