栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python刷投票的脚本实现代码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python刷投票的脚本实现代码

原理就是用代理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) 
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/35956.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号