当前位置:主页 > 软件编程 > Python代码 >

python爬虫超时的处理的实例

时间:2021-02-04 11:37:21 | 栏目:Python代码 | 点击:

如下所示:

#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) 

您可能感兴趣的文章:

相关文章