国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

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

2020-02-23 06:09:19
字體:
供稿:網(wǎng)友

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

2.7環(huá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) 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 三江| 石门县| 庄河市| 贵溪市| 安泽县| 巴林右旗| 大田县| 乳山市| 滦南县| 克拉玛依市| 蒲江县| 太谷县| 全南县| 鹰潭市| 凤阳县| 勐海县| 揭西县| 繁峙县| 辰溪县| 临高县| 固始县| 阿尔山市| 青浦区| 金乡县| 临安市| 普兰店市| 清镇市| 商洛市| 宜春市| 玉林市| 特克斯县| 县级市| 遂宁市| 八宿县| 普安县| 开原市| 璧山县| 潼关县| 新龙县| 蒲江县| 孙吴县|