源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Python中为feedparser设置超时时间避免堵塞

  • 时间:2020-02-25 17:00 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Python中为feedparser设置超时时间避免堵塞
python有一个用于解析feed的模块:feedparser,feedparser解析各种feed是非常方便的,唯一比较恼火的是遇到一些badurl,经常会导致堵塞,因此需要为feedparser设置一个超时时间。 可是feedparser并没有提供这个功能,只好采用其他方法了,具体办法请参看feedparser项目的issue221。 其实也很简单,按照上面文档的说明 developers have had the ability to set a global timeout for over seven years by importing the socket library and setting the timeout in this way:
[u]复制代码[/u] 代码如下:
import socket socket.setdefaulttimeout(<timeout in floating seconds>)
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部