处理python爬虫的timeout报错
来源:互联网 发布:kettle java脚本 编辑:程序博客网 时间:2024/05/18 15:55
尽管添加了
import socketsocket.setdefaulttimeout(timeout)
但是在爬虫过程中依然会出现Traceback (most recent call last):
File "C:\Users\wenxue5\Documents\Tencent Files\910872628\FileRecv\zongheng.py", line 93, in <module>
search(line.strip())
File "C:\Users\wenxue5\Documents\Tencent Files\910872628\FileRecv\zongheng.py", line 60, in search
the_page = response.read() #读取反馈的内容
File "C:\Python27\lib\socket.py", line 349, in read
data = self._sock.recv(rbufsize)
File "C:\Python27\lib\httplib.py", line 532, in read
return self._read_chunked(amt)
File "C:\Python27\lib\httplib.py", line 590, in _read_chunked
value.append(self._safe_read(chunk_left))
File "C:\Python27\lib\httplib.py", line 634, in _safe_read
chunk = self.fp.read(min(amt, MAXAMOUNT))
File "C:\Python27\lib\socket.py", line 378, in read
data = self._sock.recv(left)
timeout: timed out
这是因为没有对timeout进行处理造成的
import urllib2import socket#In Python 2.7.3try: urllib2.urlopen("www.baidu.com", timeout = 10)except urllib2.URLError as e: print type(e) #not catchexcept socket.timeout as e: print type(e) #catched
- 处理python爬虫的timeout报错
- pxssh报错,timeout
- python爬虫超时的处理
- python爬虫超时的处理
- Python网络爬虫报错“SSL: CERTIFICATE_VERIFY_FAILED”的解决方案
- python session过期timeout处理
- loadruner报错:Step download timeout(120 seconds)的解决方法
- loadruner报错:Step download timeout(120 seconds)的解决方法
- loadruner报错:Step download timeout(120 seconds)的解决方法
- Python爬虫--timeout设置--防止访问时间过长造成假死
- python爬虫-异常处理
- Python安装easy_install报错的处理方式
- Lock wait timeout exceeded报错
- python爬虫学习记录之报错及解决方案
- python 爬虫访问网页时候,总是报错404错误
- goagent不能用的处理办法(timeout)
- angularJs 菜单的timeout和delay处理
- Python 爬虫 urllib2异常处理
- User Defined Runtime Attributes
- Android拍照获取原图片出现问题
- 【LeetCode】Valid Sudoku
- HDOJ 题目4858 项目管理(vector水)
- 单例模式与线程
- 处理python爬虫的timeout报错
- sql server2008 用户登录失败 错误18457 解决
- ffmpeg多线程转码
- 有关session阻塞问题
- 子元素和后代元素的区别
- VS2010 远程调试
- Android开发 使用 adb logcat 显示 Android 日志
- 如何删除多余系统引导项
- UNIX网络编程——揭开网络编程常见API的面纱【下】