您的位置:首页 > 编程语言 > Python开发

Python脚本刷点击率。

2015-07-15 16:07 573 查看
新建一个文本文件,并且改名为shua.py

内容:

import urllib2
import timeit
import thread
import time
i = 0
mylock = thread.allocate_lock()
def test(no,r):
global i
url = 'http://my.csdn.net/Irvingrain'
for j in range(1,r):
req=urllib2.Request(url)
req.add_header("User-Agent","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
file = urllib2.urlopen(req)
print file.getcode();
mylock.acquire()
i+=1
mylock.release()
print i;
thread.exit_thread()

def fast():
thread.start_new_thread(test,(1,50))
thread.start_new_thread(test,(2,50))

fast()
time.sleep(15)


打开cmd,定位到shua.py这个文件目录下,并执行,该文件执行完毕后会关闭。

利用bat文件,一直循环执行这个shua.py。

新建一个文本文件,并且命名为againshua.bat。

内容:

@echo off
:asd
c:/shua.py
goto asd


注:asd只是一个标示,可以随便起一个名字,goto asd是跳转到标示处。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 脚本 bat