操作系统:Windows 7; Python 2.7.3使用Python GUI ShellPython:URLError:<urlopen错误[Errno 10060]
我想通过Python阅读一个网站,并且有几位作者使用urllib
和urllib2
库。要存储在一个变量的网站,我见过提出了类似的方法:
> Traceback (most recent call last): File "<pyshell#27>", line 1, in
> <module>
> r = urllib2.urlopen(o) File "C:\Python27\lib\urllib2.py", line 126, in urlopen
> return _opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 400, in open
> response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 418, in _open
> '_open', req) File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
> result = func(*args) File "C:\Python27\lib\urllib2.py", line 1207, in http_open
> return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1177, in do_open
> raise URLError(err) 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>
我试图绕过g
变量和:
import urllib
import urllib2
g = "http://www.google.com/"
read = urllib2.urlopen(g)
最后一行120+秒钟后生成错误试图urlopen("http://www.google.com/")
也没有成功(它会在相同的时间长度后产生相同的错误)。
在这里工作很好。你的网络工作? – 2013-04-04 21:06:30
它适用于我的Win7 + Python2.7。最可能的问题是代理。在这里看到更多:http://stackoverflow.com/questions/5620263/using-an-http-proxy-python http://stackoverflow.com/questions/2923703/why-cant-i-get-pythons-urlopen-method工作 – Sheng 2013-04-05 00:57:17
@Sheng邮政作为答案,因为这很可能就是问题所在。 – Question3CPO 2013-04-30 14:08:39