python

超轻量级php框架startmvc

python爬虫超时的处理的实例

更新时间:2020-06-16 18:42:01 作者:startmvc
如下所示:#coding:utf-8'''''Createdon2014-7-24@author:Administrator'''importurllib2try:url="http://www.baidu.com"f=

如下所示:


#coding:utf-8 
''''' 
Created on 2014-7-24 
 
@author: Administrator 
''' 
import urllib2 
try: 
 url = "http://www.baidu.com" 
 f = urllib2.urlopen(url, timeout=0) #timeout设置超时的时间 
 result = f.read() 
# print len(result) 
 print result 
except Exception,e: 
 print 'a',str(e) 

以上这篇python爬虫超时的处理的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

python 爬虫 超时