代码:
timeout = 10
socket.setdefaulttimeout(timeout)
sock = urllib2.urlopen(url)
html = sock.read()
一般情况能行,运行没问题,可有常常会突然报错
Traceback (most recent call last):
File "/usr/local/lib/python2.5/threading.py", line 486, in __bootstrap_inner
self.run()
File "spider_eastmoney.py", line 150, in run
next_page = parse_ (mysqlDB, http, html, mod_name)
File "spider_eastmoney.py", line 94, in parse_
page_html= http.get_html(pageurl)
File "/home/Spider/News/genericHttp.py", line 47, in get_html
File "/home/Spider/News/genericHttp.py", line 47, in get_html
html = sock.read()
File "/usr/local/lib/python2.5/socket.py", line 304, in read
data = self._sock.recv(rbufsize)
File "/usr/local/lib/python2.5/httplib.py", line 529, in read
s = self.fp.read(amt)
File "/usr/local/lib/python2.5/socket.py", line 328, in read
data = self._sock.recv(left)
timeout: timed out
这是什么问题,以前没遇过,我用了多线程,线程数我设为1,会不会是这个原因。
这不是很明显地写着receive timeout吗
我说,是什么原因造成的
网络情况造成的...
很正常....
这种情况需要你