Python: Urllib2 | [Errno 54] Verbindung von Peer zurückgesetzt

Ich rufe eine Liste von URLs aus derselben Domain auf und gebe einen Ausschnitt ihres HTML-Codes für ein paar tausend Domains zurück, erhalte aber diesen Fehler in etwa 1.000 Zeilen.

Kann ich irgendetwas tun, um diesen Fehler zu vermeiden?Ist es sinnvoll, nach jeder Zeile einen Warteschritt zu erstellen? alle paar hundert Zeilen?

Gibt es einen besseren Weg, dies zu umgehen?

  File "/Users.../ap.py", line 144, in <module> simpleProg()
  File "/Users.../ap.py", line 21, in simpleProg()
  File "/Users.../ap.py", line 57, in first_step()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 418, in _open 
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1180, in do_open
    r = h.getresponse(buffering=True)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1030, in getresponse
    response.begin()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 365, in _read_status
    line = self.fp.readline()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
    socket.error: [Errno 54] Connection reset by peer

Antworten auf die Frage(0)

Ihre Antwort auf die Frage