马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
一边学一边写的。
按要求貌似需要打卡50个即可,但发现可以打卡100个,如果只想打卡50个请自行替换for循环的上限数值。
import requests
import json
import time
headers = {
'Accept-Encoding': 'gzip,compress,br,deflate',
'content-type': 'application/json',
'Connection': 'keep-alive',
'Referer': 'https://servicewechat.com/wx2478a87602a76401/5/page-frame.html',
'Host': 'dj.leadmea.com',
'Authorization': '请自行抓包获取并填入,抓包打开一次小程序,搜url:leadmea查看请求头即可',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.7(0x18000729) NetType/WIFI Language/zh_CN',
'X-Requested-With': 'XMLHttpRequest'
}
# 获取景点列表和信息
def getList():
url = 'https://dj.leadmea.com/trails-many'
data = ''
r = requests.post(url=url, headers=headers, data=data)
list = json.loads(r.text)['data']['list']
return list
# print(list)
# 打卡
def checkin():
list = getList()
url = 'https://dj.leadmea.com/trails-clock'
num = len(list)
print(f'总共需打卡{num}个红色景点')
for i in range(0, len(list)):
trailsId = list[i]['id']
longitude = list[i]['longitude']
latitude = list[i]['latitude']
title_tips = list[i]["title_tips"]
data = '{"trailsId":' + trailsId + ',"longitude":' + longitude + ',"latitude":' + latitude + ',"type":1}'
r = requests.post(url=url, headers=headers, data=data)
msg = json.loads(r.text)['msg']
print(f'打卡第{trailsId}个景点:{title_tips},{msg}')
#必须等待5秒以上,否则可能会有失败景点
time.sleep(5)
if __name__ == "__main__":
checkin()
|