Created
August 31, 2012 12:54
-
-
Save greatghoul/3552337 to your computer and use it in GitHub Desktop.
中国奥运榜样刷票
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60.28.250.194:82 | |
121.15.167.231:8080 | |
122.72.0.6:80 | |
114.80.240.6:808 | |
202.112.114.17:3128 | |
221.176.14.73:80 | |
122.113.28.52:3128 | |
218.247.138.40:80 | |
211.144.76.7:8181 | |
60.190.129.52:3128 | |
210.14.148.4:80 | |
210.14.143.118:80 | |
121.8.166.36:8080 | |
120.90.11.82:8080 | |
218.94.149.114:8080 | |
113.96.239.210:8080 | |
59.34.57.68:8080 | |
112.94.146.31:8080 | |
60.28.219.218:80 | |
119.4.250.97:80 | |
180.137.45.86:8080 | |
121.33.249.170:8080 | |
218.29.54.105:80 | |
202.127.28.67:3128 | |
122.72.33.139:80 | |
123.235.12.118:8080 | |
61.135.208.184:80 | |
123.85.178.21:8000 | |
119.2.3.222:3128 | |
122.72.28.22:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
import urllib2, random | |
proxy_list = [] | |
HEADERS = [ | |
('Accept', '*/*'), | |
('Accept-Charset', 'UTF-8,*;q=0.5'), | |
('Accept-Encoding', 'gzip,deflate,sdch'), | |
('Accept-Language', 'zh-CN,zh;q=0.8'), | |
('Cache-Control', 'no-cache'), | |
('Connection', 'keep-alive'), | |
('Host', 'vote.news.163.com'), | |
('Pragma', 'no-cache'), | |
('Referer:http', '//2012.163.com/special/olympicidol/'), | |
] | |
USER_AGENT_LIST = ( | |
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)', | |
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)', | |
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', | |
'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070309 Firefox/2.0.0.3', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070803 Firefox/1.5.0.12', | |
'Opera/9.27 (Windows NT 5.2; U; zh-cn)', | |
'Opera/8.0 (Macintosh; PPC Mac OS X; U; en)', | |
'Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en) Opera 8.0', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13', | |
'Mozilla/5.0 (iPhone; U; CPU like Mac OS X) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13', | |
'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1246.0 Safari/537.8', | |
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6', | |
) | |
def read_proxy_list(): | |
for line in open('list.txt'): | |
proxy_list.append(line.strip()) | |
def random_proxy(): | |
return 'http://' + random.choice(proxy_list) | |
def rate(): | |
proxy = random_proxy() | |
logging.info('Proxy: %s', proxy) | |
proxy_handler = urllib2.ProxyHandler({"http": proxy}) | |
opener = urllib2.build_opener(proxy_handler) | |
headers = HEADERS[:] | |
headers.append(('User-Agent', random.choice(USER_AGENT_LIST))) | |
opener.add_headers = headers | |
url = 'http://vote.news.163.com/vote2/djsonpVote.do?voteid=17417&itemid=84527&callback=jsonp134640913%d' % random.randint(1000, 9999) | |
logging.info('Rating %s', url) | |
req = urllib2.Request(url) | |
resp = opener.open(req, timeout=10) | |
logging.info(resp.read()) | |
if __name__ == '__main__': | |
read_proxy_list() | |
for i in range(10): | |
try: | |
rate() | |
except Exception as e: | |
logging.warn(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment