投票程序,还能用吗

投票教程 admin 0浏览

近段在某大型技术博客上看到一串关于投票活动的投票程序通用代码,这条投票程序代码非常简洁,小编也进行了封包后,进行了测试发现存在一系列的问题,主要是投票系统现在太多了,更新也非常及时所以说投票程序必须是跟上脚步,否则网上的投票活动是不能用编程来来搞定的。现在《渔夫微信互投票群》的群主把这串投票程序代码发上来给大家看下。

投票程序,还能用吗

投票脚本如下

  1. #coding=utf-8
  2. import urllib2
  3. import urllib
  4. import re
  5. import threading
  6. import sys
  7. from time import ctime
  8. import time
  9. rlock = threading.RLock()
  10. def vote(proxyIP,i,urls):
  11.     try:
  12.         #print “voting…%d…” % i
  13.         #使用代理IP
  14.         proxy_support = urllib2.ProxyHandler(proxyIP)
  15.         opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
  16.         #定义Opener
  17.         urllib2.install_opener(opener)
  18.         #把opener绑定到全局
  19.         sendt = ‘投票’.decode(‘utf-8’).encode(‘gb2312’)
  20.         #设置刷票地址
  21.         #post数据bn
  22.         values = {}
  23.         req = urllib2.urlopen(urls)
  24.         #直接打开这个URL
  25.         html = req.read()
  26.         #读取返回数据
  27.         if html.find(‘true’.decode(‘utf-8’).encode(‘gb2312’)):
  28.             print “投票 [%d] 成功” % i
  29.             return 1
  30.         else:
  31.             print “投票 [%d] 失败” % i
  32.             return 0;
  33.     except Exception:
  34.         return False
  35. if __name__ == “__main__”:
  36.     args = sys.argv
  37.     if(len(args) == 3):
  38.         ipFile = open(args[1]);
  39.         ipList = ipFile.readlines()
  40.         ipFile.close()
  41.         length = range(len(ipList))
  42.         threads = []
  43.         for i in length:
  44.             ipLine = ipList[i]
  45.             ip=ipLine.strip()
  46.             proxy_ip = {‘http’: ip}
  47.             t = threading.Thread(target=vote,args=(proxy_ip,i,args[2]))
  48.             print “get “,args[2],ip
  49.             threads.append(t)
  50.         for i in length:
  51.             threads[i].start();
  52.             if i%100:
  53.                 time.sleep(5)
  54.                 #每100个线程等待 5秒
  55.         for i in length:
  56.             threads[i].join()
  57.     else:
  58.         print “””刷票工具
  59.                 python brush.py IP文件 Get地址:
  60.                 “””

总结:投票程序,现在还有用吗?对普通的投票还是可以的。复杂类型的投票咱们需要懂编程,否则投票系统加了验证码,那这串投票程序代码就失效了。

版权申明:本篇文章属于原创,转载请注明出自微信投票网。原文地址: https://www.aivote.com/12561.html