赞
踩
医院看病挂号,需要在微信公众号上挂号再去看病,等了两三周天天都是约满,无奈之下花了一会时间写了个脚本监控,发现有号就钉钉发消息通知我,解放双手从我做起。
代码如下:
- import ast
- import json
- import time
- import requests
-
- 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"
- hh = {
- "Host": "mp.mhealth100.com",
- "Connection": "close",
- "Accept": "application/json",
- "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",
- "Accept-Encoding": "gzip, deflate",
- "Accept-Language": "zh-CN,en-US;q=0.8",
- "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",
- "X-Requested-With": "com.tencent.mm"
- }
-
- def select_data():
- data = requests.get(url=urll, headers=hh)
- resule = data.text #所有皮肤科的数据
- return resule
-
- def jsonss(js):
- data1 = js["data"]
- data11 = data1[9]["scheduleInfos"] #9号是xx医生的序号
- for i in range(len(data11)): #data11[i]是每条单独的上午下午数据
- if data11[i]["regLeaveCount"] != "0":
- dingding(data11[i]["regDate"],data11[i]["weekName"],data11[i]["regLeaveCount"])
- else:
- pass
-
- def dingding(data,week,count):
- url = "https://oapi.dingtalk.com/robot/send?access_token=hdfkhaskdfhadhsfkhaslkdfhlkajshdfklahsdkjfhalsdfhalksdhjfkjahadfasdfasdfa"
- # 构建请求头部
- header = {
- "Content-Type": "application/json",
- "Charset": "UTF-8"
- }
- # 构建请求数据
- tex = "xx医生 时间:%s %s 剩余可挂号数量:%s" % (data,week,count)
- message = {
- "msgtype": "text",
- "text": {
- "content": tex
- },
- "at": {
- "isAtAll": False
- }
- }
- # 对请求的数据进行json封装
- message_json = json.dumps(message)
- # 发送请求
- info = requests.post(url=url, data=message_json, headers=header)
- # 打印返回的结果
- while info.ok != True:
- info = requests.post(url=url, data=message_json, headers=header)
-
- if __name__ == '__main__':
- a = 0
- while True:
- js = select_data()
- try:
- js = ast.literal_eval(js)
- data = jsonss(js)
- a+=1
- if a == 60:
- data=""
- week=""
- count="0 挂号机器人正常运行中"
- dingding(data,week,count)
- a = 0
- time.sleep(60)
- except:
- data = ""
- week = ""
- count = "0 挂号机器人token失效"
- dingding(data,week,count)
去github上搜了下,已经有大佬在维护这个类似的脚本了,可以移步去这里查看最新版本的代码。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。