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
分享到:
2013-11-05 14:10
浏览 1120
评论