Python 2.7 Python:Urllib2 |[Errno 54]对等方重置连接
我调用了来自同一个域的URL列表,并返回了数千个域的html片段,但在大约1000行中出现了这个错误Python 2.7 Python:Urllib2 |[Errno 54]对等方重置连接,python-2.7,urllib2,Python 2.7,Urllib2,我调用了来自同一个域的URL列表,并返回了数千个域的html片段,但在大约1000行中出现了这个错误 我能做些什么来避免这个错误吗 在每行之后创建一个等待步骤有意义吗?每隔几百行 有没有更好的办法解决这个问题 File "/Users.../ap.py", line 144, in <module> simpleProg() File "/Users.../ap.py", line 21, in simpleProg() File "/Users.../ap.py",
- 我能做些什么来避免这个错误吗李>
- 在每行之后创建一个等待步骤有意义吗?每隔几百行
- 有没有更好的办法解决这个问题
simpleProg()中的第144行“/Users…/ap.py” simpleProg()中的文件“/Users…/ap.py”,第21行 文件“/Users…/ap.py”,第57行,第一步() urlopen中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第126行 return\u opener.open(url、数据、超时) 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第400行,打开 响应=自身打开(请求,数据) 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第418行,打开 "开放", 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第378行,在调用链中 结果=func(*args) http_open中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第1207行 返回self.do_open(httplib.HTTPConnection,req) 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,第1180行,打开 r=h.getresponse(缓冲=True) getresponse中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第1030行 response.begin() 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第407行,在begin中 版本、状态、原因=self.\u读取\u状态() 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第365行,处于“读取”状态 line=self.fp.readline() readline中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py”,第447行 数据=self.\u sock.recv(self.\r bufsize) socket.error:[Errno 54]对等方重置连接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