Python: URLError: <urlopen error [Errno 10060]
Betriebssystem: Windows 7; Python 2.7.3 mit der Python-GUI-Shell
Ich versuche, eine Website über Python zu lesen, und mehrere Autoren verwenden dieurllib
undurllib2
Bibliotheken. Um die Site in einer Variablen zu speichern, habe ich einen ähnlichen Ansatz vorgeschlagen:
import urllib
import urllib2
g = "http://www.google.com/"
read = urllib2.urlopen(g)
Die letzte Zeile erzeugt nach mehr als 120 Sekunden einen Fehler:
> 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>
Ich habe versucht, das zu umgeheng
variabel und versucht zuurlopen("http://www.google.com/")
auch ohne Erfolg (es erzeugt den gleichen Fehler nach der gleichen Zeitspanne).