国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 澄江县| 陇南市| 江北区| 尖扎县| 阳春市| 百色市| 安塞县| 习水县| 镇安县| 呈贡县| 无为县| 祁阳县| 新晃| 颍上县| 麻阳| 运城市| 阿拉善右旗| 莆田市| 司法| 延吉市| 扶风县| 慈利县| 新龙县| 菏泽市| 拜泉县| 团风县| 乌拉特中旗| 寻乌县| 运城市| 乃东县| 乐清市| 准格尔旗| 织金县| 万安县| 临高县| 玛曲县| 福贡县| 明星| 哈密市| 班戈县| 宁晋县|