python urllib2和httplib请求的速度比较实例测试,urllib2httplib,我要做一个事情,需要请求
python urllib2和httplib请求的速度比较实例测试,urllib2httplib,我要做一个事情,需要请求
我要做一个事情,需要请求几万个网站,每个网站请求几百次,来获取网页状态码和html内容。
测试了下httplib的速度是urllib2的好几倍
import timeprint time.time()import urllib2response = urllib2.urlopen('http://www.CodeSnipp.cn/') print response.getcode() a=response.read() response.close()print time.time()import httplib conn = httplib.HTTPConnection("www.CodeSnipp.cn") conn.request('get', '/')res = conn.getresponse() print res.status b=res.read()conn.close() print time.time()#该片段来自于http://byrx.net
相关内容
- 使用python下载网页上的flash,pythonflash,[Python]代码''
- Python 批量获取《oschina》高亮代码区域源码!,python《
- Find bridges of graph,bridgesgraph,[Python]代码#
- 用Python实现一个简单的算术游戏,python实现算术,#!/us
- 绑定修改网卡绑定关系脚本,修改网卡绑定脚本,[Pyth
- 判断图片分辨率并修改,判断图片分辨率,[Python]代码
- 调节图片亮度和饱和度,图片亮度饱和度,[Python]代码
- 九九乘法表,乘法,[Python]代码im
- 从WeatherCN上提取天气数据,weathercn提取天气,# -*- codin
- Python信息录入小系统(使用shelve),pythonshelve,Python s
评论关闭