python实现签到抽奖收集bug

import requests
from apscheduler.schedulers.blocking import BlockingScheduler
from datetime import datetime
import time
import random

cookie = '自己的cookie'
header = {
    'cookie': cookie
}
# 具体参数
aid = '自己的aid'
uuid = '自己的uuid'
spider = '自己的spider'
# 签到
checkInUrl = 'https://*/check_in'
# 抽奖
drawUrl = 'https://*/draw'
# 未收集bug的列表
notCollectUrl = 'https://*/not_collect'
# 收集bug
collectUrl = 'https://*/collect'


# 签到
def sign_in():
    r = requests.post(
        checkInUrl,
        params={
            'aid': aid,
            'uuid': uuid,
            'spider': spider
        },
        headers=header
    )
    print(r.text)


# 抽奖
def draw():
    r = requests.post(
        drawUrl,
        params={
            'aid': aid,
            'uuid': uuid,
            'spider': spider
        },
        headers=header
    )
    print(r.text)


# 收集bug
def collect():
    # 获取未收集bug列表
    r = requests.post(
        notCollectUrl,
        params={
            'aid': aid,
            'uuid': uuid,
            'spider': spider
        },
        headers=header
    )
    reason = r.json()
    if reason['err_msg'] == 'success':
        for notCollectItem in reason['data']:
            # 收集bug
            r_item = requests.post(
                collectUrl,
                params={
                    'aid': aid,
                    'uuid': uuid,
                    'spider': spider
                },
                data={
                    'bug_time': notCollectItem['bug_time'],
                    'bug_type': notCollectItem['bug_type']
                },
                headers=header
            )
            print(r_item.text)
    print(r.text)


def job():
    time.sleep(random.randint(0, 60))
    # 打印当前时间
    print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    # 签到
    sign_in()

    time.sleep(random.randint(0, 60))
    # 打印当前时间
    print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    # 抽奖
    draw()

    time.sleep(random.randint(0, 60))
    # 打印当前时间
    print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    # 收集bug
    collect()


if __name__ == "__main__":
    # 每天早上八点半签到
    scheduler = BlockingScheduler(timezone='Asia/Shanghai')
    scheduler.add_job(job, 'cron', day_of_week='0-6', hour=8, minute=30)
    scheduler.start()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值