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

相关文章:

  • 2021-10-05
  • 2021-08-19
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-01-12
  • 2021-12-19
  • 2022-02-03
相关资源
相似解决方案