python刷博客访问量
来源:互联网 发布:r语言数据框分类汇总 编辑:程序博客网 时间:2024/04/25 15:00
import mechanizeimport cookielibfrom time import ctime,sleepdef run(): print 'start!' for i in range(100): browse() print "run",i,"times ",ctime() sleep(1)def browse(): br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) br.set_handle_equiv(True) br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] r = br.open('http://blog.csdn.net/zhou_yujia/article/details/70115839') html = r.read() #print htmlrun()
多线程版:
import mechanizeimport cookielibimport threadingfrom time import ctime,sleepdef run(): print 'start!' for i in range(100): browse() print "run",i,"times ",ctime() sleep(1)def browse(): br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) br.set_handle_equiv(True) br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] r = br.open('http://blog.csdn.net/zhou_yujia/article/details/52319009') html = r.read() #print htmlif __name__ == '__main__': threads = [] for i in range(500): t1=threading.Thread(target=run) threads.append(t1) for t in threads: t.setDaemon(True) t.start() print "all over %s" %ctime()#run()
阅读全文
0 0
- python刷博客访问量
- python爬虫之csdn刷博客访问量
- python爬虫设计刷博客访问量(刷访问量,赞,爬取图片)
- Python 刷网页访问量
- Python 刷网页访问量
- Python--刷csdn访问量
- Python刷csdn访问量
- python项目之 增加博客访问量
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- python爬取博客标题和访问量
- Python爬虫爬取博客访问量
- 使用python爬取csdn博客访问量
- python爬取自己博客访问量
- 如何刷博客的访问量
- 如何刷博客的访问量
- easyui easyui-layout 调整布局大小
- KETTLE整库迁移方案(SQL server迁移至Mysql,迁移过程自动创建表结构)
- SVN 学习笔记
- cocosstudio3.0版本以上动画在C++中使用浅析
- ejb是什么?
- python刷博客访问量
- X265源码下载地址
- 欧拉函数概念及其证明
- Java并发编程:Callable、Future和FutureTask的实现
- jdk6+(不含6) 比较规则遵循规则:对称,反身,传递!
- oracle 创建存储过程 遍历操作
- Java_异常处理
- 二次手撕线段树区间更新
- 万物互联大数据研究正式展开人才紧缺