欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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
相关标签: python