Python中为feedparser设置超时时间教程
2014-09-26 16:26
555 查看
python有一个用于解析feed的模块:feedparser,feedparser解析各种feed是非常方便的,唯一比较恼火的是遇到一些badurl,经常会导致堵塞,因此需要为feedparser设置一个超时时间。
可是feedparser并没有提供这个功能,只好采用其他方法了,具体办法请参看feedparser项目的issue221。
其实也很简单,按照上面文档的说明
developers hav(www.111cn.net)e had the ability to set a global timeout for over seven years by importing the socket library and setting the timeout in this way:
import socket
socket.setdefaulttimeout(<timeout in floating seconds>)
from:http://www.111cn.net/phper/python/66849.htm
可是feedparser并没有提供这个功能,只好采用其他方法了,具体办法请参看feedparser项目的issue221。
其实也很简单,按照上面文档的说明
developers hav(www.111cn.net)e had the ability to set a global timeout for over seven years by importing the socket library and setting the timeout in this way:
import socket
socket.setdefaulttimeout(<timeout in floating seconds>)
from:http://www.111cn.net/phper/python/66849.htm
相关文章推荐
- Python中为feedparser设置超时时间避免堵塞
- Python中为feedparser设置超时时间避免堵塞
- Python urllib2 设置超时时间
- python脚本设置超时机制系统时间的方法
- Python2.x设置命令执行的超时时间
- python字节序转换+设置套接字超时时间
- selenium设置元素发现超时等待时间-python
- python脚本设置超时机制系统时间的方法
- python subprocess模块 监控子进程的2种方式 忙等待和立即返回同时设置子进程超时时间
- Python调用系统命令设置超时时间
- 【python】Django设置SESSION超时时间没有生效?
- python的 http/soap设置超时时间
- Python 2.x如何设置命令执行的超时时间实例
- python有超时的windows系统时间设置代码
- Python urllib2 设置超时时间
- python http,或者soap设置超时时间
- python运用redis,存储键值,设置超时时间
- Python urllib2 设置超时时间并处理超时异常
- python TCPServer, StreamRequestHandler设置超时时间timeout
- ASP.NET连接超时时间设置