python刷投票的脚本实现代码
2014-11-08 20:16
471 查看
原理就是用代理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)
您可能感兴趣的文章:
相关文章推荐
- python刷投票的脚本实现代码
- python自动化工具日志查询分析脚本代码实现
- Python脚本实现代码行数统计代码分享
- 用python脚本实现的android代码管理工具rrdt
- Python实现自动添加脚本头信息的示例代码
- python自动化工具日志查询分析脚本代码实现
- Python脚本实现代码行数统计代码分享
- 实现在Java中执行python代码或py脚本(可传参数)
- python脚本实现统计日志文件中的ip访问次数代码分享
- 将C++代码全部写到头文件:)python脚本帮助自动生成相应的实现文件初始框架
- python脚本实现统计日志文件中的ip访问次数代码分享
- Python实现自动添加脚本头信息的示例代码
- 实现通用 Web CAPTCHA 图形验证码 JavaScript 脚本 API 服务 (JavaScript 脚本动态页面引用) 完整代码
- Run As(运行方式) 的几种代码实现方式(Python和C#)
- 一个cssQuery对象 javascript脚本实现代码
- vbs实现的eMule电驴自动关机脚本代码
- 使用jscript实现二进制读写脚本代码
- python 查找文件夹下所有文件 实现代码
- 用JavaScript实现UrlEncode和UrlDecode的脚本代码