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()
python实现签到抽奖收集bug
于 2023-04-13 11:31:00 首次发布