HTTP Referer is a part of the header. When a browser sends a request to a web server, it usually carries a Referer to tell the server which page the link is from, the server obtains some information for processing. Used to measure traffic volume and prevent external connections.
Import httplib, urllib2
Import random
Import time
I = 0
While 1:
A = random. random ()
B = str ()
Url = 'HTTP: // page.vote.qq.com/survey.php? PjtID = 2439626 & SubjID = 2493278 & OptID = 184964 & fmt = json & result = 0 & rdm = '+ B + '000000'
Httplib. HTTPConnection. debuglevel = 1
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") www.2cto.com
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.20.6.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)