相关疑难解决方法(0)

使用HTTP PROXY - Python

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

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

>>> urllib2.urlopen("http://www.google.com").read()
Run Code Online (Sandbox Code Playgroud)

回报

urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
Run Code Online (Sandbox Code Playgroud)

要么

urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Run Code Online (Sandbox Code Playgroud)

额外信息:

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>      
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

python proxy http urllib2

45
推荐指数
3
解决办法
17万
查看次数

标签 统计

http ×1

proxy ×1

python ×1

urllib2 ×1