urllib2.urlopen(url,timeout=10).read() 循环采集 如果一超时后报错 然后就停止运行了
请问一下如果超时了还让程序继续运行下去!
Traceback (most recent call last):
File "E:\PYTHON EXAMPLE\robot.py", line 114, in <module>
runTask(work, day=0, hour=0, min=0, second=5)
File "E:\PYTHON EXAMPLE\robot.py", line 104, in runTask
func()
File "E:\PYTHON EXAMPLE\robot.py", line 55, in work
bk_browse = urllib2.urlopen(url,timeout=10).read()
File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27\lib\urllib2.py", line 1200, in do_open
r = h.getresponse(buffering=True)
File "C:\Python27\lib\httplib.py", line 1074, in getresponse
response.begin()
File "C:\Python27\lib\httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "C:\Python27\lib\httplib.py", line 371, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "C:\Python27\lib\socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054]
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.