鱼C论坛

 找回密码
 立即注册
查看: 1808|回复: 0

[技术交流] 打卡广东红小程序

[复制链接]
发表于 2021-6-17 17:01:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
一边学一边写的。

按要求貌似需要打卡50个即可,但发现可以打卡100个,如果只想打卡50个请自行替换for循环的上限数值。

  1. import requests
  2. import json
  3. import time

  4. headers = {
  5.     'Accept-Encoding': 'gzip,compress,br,deflate',
  6.     'content-type': 'application/json',
  7.     'Connection': 'keep-alive',
  8.     'Referer': 'https://servicewechat.com/wx2478a87602a76401/5/page-frame.html',
  9.     'Host': 'dj.leadmea.com',
  10.     'Authorization': '请自行抓包获取并填入,抓包打开一次小程序,搜url:leadmea查看请求头即可',
  11.     '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',
  12.     'X-Requested-With': 'XMLHttpRequest'
  13. }

  14. # 获取景点列表和信息
  15. def getList():
  16.     url = 'https://dj.leadmea.com/trails-many'
  17.     data = ''
  18.     r = requests.post(url=url, headers=headers, data=data)
  19.     list = json.loads(r.text)['data']['list']
  20.     return list


  21.     # print(list)

  22. # 打卡
  23. def checkin():
  24.     list = getList()
  25.     url = 'https://dj.leadmea.com/trails-clock'
  26.     num = len(list)
  27.     print(f'总共需打卡{num}个红色景点')
  28.     for i in range(0, len(list)):
  29.         trailsId = list[i]['id']
  30.         longitude = list[i]['longitude']
  31.         latitude = list[i]['latitude']
  32.         title_tips = list[i]["title_tips"]
  33.         data = '{"trailsId":' + trailsId + ',"longitude":' + longitude + ',"latitude":' + latitude + ',"type":1}'
  34.         r = requests.post(url=url, headers=headers, data=data)
  35.         msg = json.loads(r.text)['msg']
  36.         print(f'打卡第{trailsId}个景点:{title_tips},{msg}')
  37.         #必须等待5秒以上,否则可能会有失败景点
  38.         time.sleep(5)

  39. if __name__ == "__main__":
  40.     checkin()
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-1 15:04

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表