美文网首页
多URL爬虫超时问题

多URL爬虫超时问题

作者: 苟雨 | 来源:发表于2017-02-23 22:07 被阅读20次

urllib2 的超时问题
如果写爬虫除非为每一个URL开一个线程,不然就不可能绕开Timeout的影响,
每次超时后就会暂停程序。
用下面这段程序来跳过超时的部分,

try:

except Exception as e:
  print str(e)

扫码获取源码

还有就可以用协程(python3标准库已经原生支持);

相关文章

网友评论

      本文标题:多URL爬虫超时问题

      本文链接:https://www.haomeiwen.com/subject/uctiwttx.html