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

首頁 > 編程 > Python > 正文

python刷投票的腳本實現代碼

2019-11-25 18:06:26
字體:
來源:轉載
供稿:網友

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

2.7環境下運行

#!/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) 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 五原县| 古浪县| 北安市| 北流市| 肥城市| 绥中县| 沾化县| 玉田县| 如东县| 梁河县| 德江县| 汉源县| 屏山县| 元江| 大港区| 保山市| 石首市| 镇赉县| 巴南区| 扎兰屯市| 徐州市| 东乡族自治县| 瓮安县| 乌兰浩特市| 浦北县| 灵台县| 临江市| 扶绥县| 大荔县| 溆浦县| 师宗县| 广汉市| 铜梁县| 塔河县| 山阴县| 黄浦区| 玛多县| 龙游县| 温泉县| 崇礼县| 合江县|