小爬虫之博客刷博器

来源:互联网 发布:网络客服人员工作职责 编辑:程序博客网 时间:2024/05/19 01:32

一、刷新博客的浏览次数:

#!/usr/bin/env python#coding=utf-8import webbrowser as webimport timeimport osimport randomcount = random.randint(10, 20)    #产生随机数j = 0;while j < count:i = 0while i < 3:                #循环打开次数web.open_new_tab('http://blog.csdn.net/yuan_lo/article/details/39453003')   #要刷的博客i = i + 1time.sleep(0.8)                   #让进程停留0.8,os.system('killall firefox')              #关闭浏览器j = j + 1

二、下载网页到本地

import urllibimport webbrowser as web#coding=utf-8url = 'http://163.com'content = urllib.urlopen(url).read()      #读取html代码open('163.html','w').write(content)      #将代码写入163.html文档中web.open_new_tab('file:///home/yuan/163.html')          #用浏览器打开网页




0 0
原创粉丝点击