Python 進行HTTP代理 多執行緒實現微信刷投票開發
阿新 • • 發佈:2019-02-08
這幾天朋友參加比賽需要,就寫了個指令碼幫忙刷投票.
我們首先來到要投票的網站上來看看。
隨便找一個投上一票
居然不用登陸,當然是每個IP只能投一票。
開啟Chrome dev tools, 看一下
Get請求。
那直接把Request URL複製下來,這個就是用於刷票的URL 微信拓客
按理來說只要把這個URL 發給任何一個人誘惑他點開,就是幫你投票了。
他返回了一個Json資料格式。告訴我們已經投過票了。
然後我們登VPN 換一個IP 試試看。
Json “Total” 名稱 就是當前的票數。“result”為true 顯然告訴我們投票成功了。
那的確是這樣的。
然後想要刷票呢,我們需要找一些開放HTTP代理的IP。我找了半天然後推薦 這個網站 可以直接抓取IP到這種格式。
由於我沒有長期接觸過Python 網路方面的程式設計。以前也只是看著用Requests庫爬了一些小網站的資料。
可以先看下這篇博文
#coding=utf-8 import urllib2 import urllib import re import threading import sys from time import ctime import time rlock = threading.RLock() def vote(proxyIP,i,urls): try: #print "voting...%d..." % i #使用代理IP proxy_support = urllib2.ProxyHandler(proxyIP) opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler) #定義Opener urllib2.install_opener(opener) #把opener繫結到全域性 sendt = '投票'.decode('utf-8').encode('gb2312') #設定刷票地址 #post資料bn values = {} req = urllib2.urlopen(urls) #直接開啟這個URL html = req.read() #讀取返回資料 if html.find('true'.decode('utf-8').encode('gb2312')): print "投票 [%d] 成功" % i return 1 else: print "投票 [%d] 失敗" % i return 0; except Exception: return False if __name__ == "__main__": args = sys.argv if(len(args) == 3): ipFile = open(args[1]); ipList = ipFile.readlines() ipFile.close() length = range(len(ipList)) threads = [] for i in length: ipLine = ipList[i] ip=ipLine.strip() proxy_ip = {'http': ip} t = threading.Thread(target=vote,args=(proxy_ip,i,args[2])) print "get ",args[2],ip threads.append(t) for i in length: threads[i].start(); if i%100: time.sleep(5) #每100個執行緒等待 5秒 for i in length: threads[i].join() else: print """刷票工具 python brush.py IP檔案 Get地址: """
然後我們執行來看看結果
原來的票數
運行了15分鐘之後
微信刷投票軟體