最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python刷投票的腳本實現(xiàn)代碼

 更新時間:2014年11月08日 20:16:12   投稿:mdxy-dxy  
這篇文章主要介紹了寫了個python刷投票的腳本,需要的朋友可以參考下

原理就是用代理IP去訪問投票地址。用到了多線程,速度飛快。
昨晚兩個小時就刷了1000多票了,主要是代理IP不好找。

2.7環(huán)境下運(yùn)行

#!/usr/bin/env python 
#-*- coding: utf-8 -*- 
 
import urllib2 
from threading import Thread 
from time import time 
 
class Vote(Thread): 
    def __init__(self, proxy): 
        Thread.__init__(self)         
        self.proxy = proxy 
        self.url = 'http://www.studentboss.com/zhuanti/2014/cncc/vote.php?id=19'
        self.timeout = 10
 
    def run(self): 
        proxy_handle = urllib2.ProxyHandler({"http": r'http://%s' % self.proxy}) 
        opener = urllib2.build_opener(proxy_handle) 
        urllib2.install_opener(opener) 
        try: 
            req = urllib2.urlopen(self.url, timeout=self.timeout) 
            result = req.read().decode('gbk') 
            print result 
            pos = result.find(u'成功') 
            if pos > 1: 
                addnum() 
            else: 
                pass
        except Exception,e: 
            print e.message,'error'    
 
 
def addnum(): 
    global n 
    n += 1
 
def shownum(): 
    return n 
 
n = 0
 
threads = [] 
 
proxylist = open('proxy.txt', 'r') 
 
for proxy in proxylist: 
    t = Vote(proxy) 
    threads.append(t) 
 
 
if __name__ == '__main__': 
    start_time = time() 
    for i in threads: 
        i.start() 
    for i in threads: 
        i.join() 
    print '%s votes have been voted successfully using %s seconds' % (shownum(), time()-start_time) 

相關(guān)文章

最新評論

扎囊县| 郑州市| 三台县| 苏尼特左旗| 根河市| 铅山县| 平昌县| 吉隆县| 普兰县| 玛多县| 海安县| 三门峡市| 乐业县| 九江市| 抚松县| 西乌珠穆沁旗| 加查县| 彭州市| 武宁县| 马公市| 鹿邑县| 扎兰屯市| 汽车| 格尔木市| 汕尾市| 启东市| 三原县| 高唐县| 忻州市| 德阳市| 隆化县| 镇远县| 辽阳市| 怀化市| 泽普县| 大悟县| 和硕县| 安远县| 易门县| 观塘区| 宜丰县|