当前位置:   article > 正文

python实现微信医院挂号查询,并钉钉实时通知_微信医院挂号脚本

微信医院挂号脚本

医院看病挂号,需要在微信公众号上挂号再去看病,等了两三周天天都是约满,无奈之下花了一会时间写了个脚本监控,发现有号就钉钉发消息通知我,解放双手从我做起。

代码如下:

  1. import ast
  2. import json
  3. import time
  4. import requests
  5. urll = "https://xxxxxxxxx.com/gateway/registration/appointment/schedule/find?branchCode=1234&deptId=1234&deptName=xxxxxx&deptType=&startDate=2020-11-23&endDate=2020-11-28&ajaxConfig=true"
  6. hh = {
  7. "Host": "mp.mhealth100.com",
  8. "Connection": "close",
  9. "Accept": "application/json",
  10. "User-Agent": "Mozilla/5.0 (Linux; Android 6.0.1; MuMu Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36 MMWEBID/2023 MicroMessenger/7.0.17.1720(0x27001134) Process/tools WeChat/arm32 NetType/NON_NETWORK Language/zh_CN ABI/arm32",
  11. "Accept-Encoding": "gzip, deflate",
  12. "Accept-Language": "zh-CN,en-US;q=0.8",
  13. "Cookie": "wechat_openId=ajdfahdflkahdlkfhaklhdfkljhadf; providerId=wechat; wechat_access_token=kahjdkjfhalkdjhflajkhdflkahdklfhj-JzUhxxyVdU77pwzEM-jkadfhlkjdhfklahdsflkjahsdkjlfhalkjsdhflajhsdfkjah; token=IWeAxxxd5-gpzJyxxxYSKg; userId=xxxxxxxxxxxxxxxxx; Hm_lvt_4f5e6d65812072c49089f06245234523452345=1606104987; Hm_lpvt_4f5e6d65812072c49089f24523452345234=1606101234",
  14. "X-Requested-With": "com.tencent.mm"
  15. }
  16. def select_data():
  17. data = requests.get(url=urll, headers=hh)
  18. resule = data.text #所有皮肤科的数据
  19. return resule
  20. def jsonss(js):
  21. data1 = js["data"]
  22. data11 = data1[9]["scheduleInfos"] #9号是xx医生的序号
  23. for i in range(len(data11)): #data11[i]是每条单独的上午下午数据
  24. if data11[i]["regLeaveCount"] != "0":
  25. dingding(data11[i]["regDate"],data11[i]["weekName"],data11[i]["regLeaveCount"])
  26. else:
  27. pass
  28. def dingding(data,week,count):
  29. url = "https://oapi.dingtalk.com/robot/send?access_token=hdfkhaskdfhadhsfkhaslkdfhlkajshdfklahsdkjfhalsdfhalksdhjfkjahadfasdfasdfa"
  30. # 构建请求头部
  31. header = {
  32. "Content-Type": "application/json",
  33. "Charset": "UTF-8"
  34. }
  35. # 构建请求数据
  36. tex = "xx医生 时间:%s %s 剩余可挂号数量:%s" % (data,week,count)
  37. message = {
  38. "msgtype": "text",
  39. "text": {
  40. "content": tex
  41. },
  42. "at": {
  43. "isAtAll": False
  44. }
  45. }
  46. # 对请求的数据进行json封装
  47. message_json = json.dumps(message)
  48. # 发送请求
  49. info = requests.post(url=url, data=message_json, headers=header)
  50. # 打印返回的结果
  51. while info.ok != True:
  52. info = requests.post(url=url, data=message_json, headers=header)
  53. if __name__ == '__main__':
  54. a = 0
  55. while True:
  56. js = select_data()
  57. try:
  58. js = ast.literal_eval(js)
  59. data = jsonss(js)
  60. a+=1
  61. if a == 60:
  62. data=""
  63. week=""
  64. count="0 挂号机器人正常运行中"
  65. dingding(data,week,count)
  66. a = 0
  67. time.sleep(60)
  68. except:
  69. data = ""
  70. week = ""
  71. count = "0 挂号机器人token失效"
  72. dingding(data,week,count)

去github上搜了下,已经有大佬在维护这个类似的脚本了,可以移步去这里查看最新版本的代码。

https://www.wpsshop.cn/w/我家小花儿/article/detail/174048?site

推荐阅读
相关标签
  

闽ICP备14008679号