简单的python刷票程序

看到班级里老师要求家长每天登陆帮九江点赞,然后我就写了个小程序,目的是为了给家长省点时间,也给九江增加点人气。

这个网址刷票的代码很简单(不涉及登录和验证),就是在网页点击小红心(点赞),找到对应的刷票链接(一般是get请求)。

完整代码如下:

#!/usr/bin/python

# coding=utf-8
import time
import random
import requests


def run():
   
while True:
        url =
'https://s.wcd.im/ajax/log_h.jsp?cmd=dog&dogId=2000496&dogSrc=2&aid=15897763&flyerAid=2781483&flyerId=283'  # 投票链接
        url2 = "https://s.wcd.im/index.jsp?id=2ks9bZ8r&flyerAid=2ks9b&loading=1&sid=9epe&chl=&isRemVersion=true"  # 返回结果链接
        try:
            req_header = {
               
"Host": "s.wcd.im",
               
"Referer": "https://s.wcd.im/index.jsp?id=2ks9bZ8r&flyerAid=2ks9b&loading=1&sid=9epe&chl=&isRemVersion=true",
               
"Sec-Fetch-Dest": "empty",
               
"Sec-Fetch-Mode": "cors",
               
"Sec-Fetch-Site": "same-origin",
               
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
               
"X-Requested-With": "XMLHttpRequest"
           
}
            response = requests.get(url
, req_header)
           
if response.status_code == 200:
                response2 = requests.get(url2
, req_header)
                html =
str(response2.content, "utf-8")
               
print(html[html.find("全城接力"):(html.find("九江代言的人") + 6)])
       
except Exception as e:
           
print(e.__str__())
           
continue
       
time.sleep(2.5*random.randint(2, 10))


if __name__ == '__main__':
    run()

 

 

执行后效果如下:

 

 

 

 

 

 

 

 

 

  • 2
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Trisyp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值