python自动投票测试
程序员文章站
2022-06-06 10:56:16
...
import httplib,urllib2 import random import time i = 0 while 1: a = random.random() b = str(a) url = 'http://page.vote.qq.com/survey.php?PjtID=2439626&SubjID=2493278&OptID=184964&fmt=json&result=0&rdm='+b+'05827' httplib.HTTPConnection.debuglevel = 1 '''request = urllib2.Request("http://page.vote.qq.com/survey.php?PjtID=2439626&SubjID=2493278&OptID=184964&fmt=json&result=0&rdm=0.18616481933105827")''' request = urllib2.Request(url) request.add_header("Accept", "*/*") request.add_header('Referer', "http://v.qq.com/zt2012/cstvf2012/tvactor.htm") request.add_header("Accept-Language", "zh-cn") request.add_header("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; MyIE9; BTRS123646; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)") request.add_header("Accept-Encoding", "gzip, deflate") request.add_header("Host", "page.vote.qq.com") request.add_header("Connection", "Keep-Alive") opener = urllib2.build_opener() f = opener.open(request) print f.url i += 1 print i time.sleep(60)
代码来自:http://www.python-cn.cn/daima/594.html
下一篇: iPhone消息推送机制实现与探讨