用python脚本24小时刷浏览器的访问量方法
作者:afterrains 时间:2022-07-16 18:21:33
如下所示:
# -*- coding=utf-8 -*-
import urllib2
import socket
import time
urls = raw_input("Please enter a web address: \n> ")
print "\nAccess web page start..."
brushNum = 3600
for i in range(brushNum):
url = urls
socket.setdefaulttimeout
req_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
'Accept':'text/html;q=0.9,*/*;q=0.8',
'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding':'gzip',
'Connection':'close',
'Referer':None
}
req_timeout = 60
req = urllib2.Request(url,None,req_header)
resp = urllib2.urlopen(req,None,req_timeout)
html = resp.read()
print "Success!\t",i + 1
print "Rest 10 seconds to continue...\n"
time.sleep(10)
这次重构了代码,运行脚本会提示输入需要刷新的网页,刷新次数默认为3600,超时时间改为120秒,这样效果好一点。
来源:https://blog.csdn.net/happy_jijiawei/article/details/53606468
标签:python,浏览器,访问量
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SQL学习笔记二 创建表、插入数据的语句
2011-09-30 11:17:32
asp中的rs.open与conn.execute的区别说明
2011-02-24 10:56:00
python实现LRU热点缓存及原理
2022-01-08 01:26:15
python sqlite的Row对象操作示例
2023-07-23 17:08:55
Python数据分析pandas模块用法实例详解
2023-01-25 00:47:29
JS+CSS实现仿支付宝菜单选中效果代码
2023-10-05 07:29:01
![](https://img.aspxhome.com/file/2023/2/56352_0s.png)
jupyter notebook 重装教程
2022-07-20 09:38:02
![](https://img.aspxhome.com/file/2023/9/76779_0s.jpg)
python requests包的request()函数中的参数-params和data的区别介绍
2021-05-04 18:21:13
![](https://img.aspxhome.com/file/2023/9/103689_0s.jpg)
写了一个小巧的jquery拾色工具
2009-12-21 14:22:00
![](https://img.aspxhome.com/file/UploadPic/20101/11/20091110144913-23s.gif)
tensorflow 实现从checkpoint中获取graph信息
2023-01-05 09:38:41
几个好用的Asp自定义函数
2007-09-26 14:28:00
Python文件的应用之序列化与反序列化详解
2021-06-19 22:20:45
![](https://img.aspxhome.com/file/2023/1/92251_0s.jpg)
python使用Pandas库提升项目的运行速度过程详解
2021-07-21 12:42:29
![](https://img.aspxhome.com/file/2023/8/115708_0s.jpg)
在 Python 中接管键盘中断信号的实现方法
2022-11-25 15:14:55
![](https://img.aspxhome.com/file/2023/5/118395_0s.jpg)
Python cookbook(数据结构与算法)从任意长度的可迭代对象中分解元素操作示例
2023-12-28 10:13:11
![](https://img.aspxhome.com/file/2023/2/107532_0s.png)
关于tensorflow的几种参数初始化方法小结
2023-10-15 12:05:26
Python实现二维数组输出为图片
2022-10-07 21:49:55
点选TOP后并不是直接跳到页顶的,而是滚动上去
2023-09-07 02:36:43
解决python虚拟环境切换无效的问题
2023-02-01 14:37:50
![](https://img.aspxhome.com/file/2023/0/77860_0s.jpg)
CSS高级文字排版的实例
2009-03-24 20:56:00