操作系統: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