使用HTTP PROXY - Python

我很熟悉我应该将HTTP_RPOXY环境变量设置为代理地址。


一般urllib工作正常,问题是处理urllib2。


>>> urllib2.urlopen("http://www.google.com").read()

回报


urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>

要么


urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

额外信息:

urllib.urlopen(....)工作正常!只是urllib2正在玩耍...

我试过@Fenikso的答案,但我现在收到这个错误:


URLError: <urlopen error [Errno 10060] A connection attempt failed because the 

connected party did not properly respond after a period of time, or established

connection failed because connected host has failed to respond>      

有任何想法吗?


慕哥6287543
浏览 1070回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP