###我已经将数据爬取出来###
现在开源集合大家的思路一起研究
(请更换ip 以及 暂停时间 不然会提示违规操作)
脚本读取预约信息后开始随机抢一家的,qiang方法里面请自行修改抓包数据参数!!
现在开源大家一起讨论
python代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
import random
import json
import time
# 抓包信息填入
from_date="2021-09-07"#今日日期 请注意格式
end_date="2021-09-14"#14
reg_data="2017-2-20"
Authorization="DYT eyJhbGciOiJIUzI1NiJ9.eyJ3ZWNoYXRfaWQiOjQyMDM5NTUsInN1YnNjcmliZSI6MCwiZHpqX3N1YnNjcmliZSI6MCwib3BlbmlkIjoib19VMzZzNE0yclR0M0NZbG5Zb05jZnZ3UnIwWSIsInRoaXJkX3VzZXJfaWQiOiIiLCJpc3MiOiJkeXQiLCJuZXdfc3Vic2NyaWJlIjowLCJuZXdfb3BlbmlkIjoiIiwiZHpqX29wZW5pZCI6IiIsInVzZXJfaWQiOjI4ODg1MTUsIndlY2hhdF9vcGVuX2lkIjoib19VMzZzNE0yclR0M0NZbG5Zb05jZnZ3UnIwWSIsInVuaW9uX2lkIjoib05RejQwWHpPVkRMdW1acmpBTDZEd1M3NUpCQSIsIm1vY2tfb3BlbmlkIjpmYWxzZSwibWluaV9vcGVuaWQiOiJvaUE0UDVFcnFIdFpFeW5MdjVjbjJTSWRhVlpJIiwiZXhwIjoxNjMxMDI2NDIwLCJpYXQiOjE2MzEwMjA4MjB9.d_wdcEKoUY6yXFPdkZpqk_LbA8pnVuTAS7VP3siM36g"
x_uuid="058F41FDBC3F09683D4E3A96505A4BA8"
acw_tc="0bdd34c216310199867268852e01a12d34c1660f204dfaa7363155fb5343ed"
def dlogin():host = "https://newdytapi.ynhdkc.com/index/hospital/871958/depart"#其他医院请更改871958 华山871958params = {}headers = {"Host": "newdytapi.ynhdkc.com",'Connection': 'keep-alive',"Accept": "application/json, text/plain, */*","User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat",# "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Authorization": Authorization,"x-uuid": x_uuid,"Origin": "https://appv2.ynhdkc.com","X-Requested-With": "com.tencent.mm","Sec-Fetch-Site": "same-site","Sec-Fetch-Mode": "cors","Sec-Fetch-Dest": "empty","Referer": "https://appv2.ynhdkc.com/","Accept-Encoding": "gzip, deflate","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"}cookies = {"acw_tc": acw_tc}r = requests.get(host, data=params)print("函数dlogn\n",r.json())# debug = r.json()code = r.json()['data']['dep_list'][0]msg = r.json()['code']if msg != 1:print("获取不到信息请检查接口")else:# print(code)print("======继续执行!!!======")tmp_dep_id = str(code['dep_id'])print("以获取===dep_id===hos_code")global dep_id,hos_codedep_id = code['dep_id']hos_code=code['hos_code']tmp_dep_name = str(code['dep_name'])tmp_hos_code = str(code['hos_code'])print("dep_id:", tmp_dep_id)print("dep_name:", tmp_dep_name)print("hos_code:", tmp_hos_code)print("======开始监控疫苗开抢状态======")dier(tmp_dep_id,tmp_dep_name,tmp_hos_code)# 变量存入
def dier(tmp_dep_id,tmp_dep_name,tmp_hos_code):host = "https://newdytapi.ynhdkc.com/index/doctor?hos_code="+tmp_hos_code+"&dep_id="+tmp_dep_id+"&from_date="+from_date+"&end_date="+end_date+"®_date="+reg_data+"&other_info=undefined&vip=0"# 其他医院请更改871958 华山871958params = {}headers = {"Host": "newdytapi.ynhdkc.com",'Connection': 'keep-alive',"Accept": "application/json, text/plain, */*","User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Authorization": Authorization,"x-uuid": x_uuid,"Origin": "https://appv2.ynhdkc.com","X-Requested-With": "com.tencent.mm","Sec-Fetch-Site": "same-site","Sec-Fetch-Mode": "cors","Sec-Fetch-Dest": "empty","Referer": "https://appv2.ynhdkc.com/","Accept-Encoding": "gzip, deflate","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"}cookies = {"acw_tc": acw_tc}print(host)r = requests.get(host, data=params, headers=headers, cookies=cookies)debug = r.json()['data'][5]# 2为重组 5为九价其他请自行抓包print("========================",debug)print("存入全局:======")print("doc_id",debug['doc_id'])global doc_iddoc_id = debug['doc_id']print("doc_id存入全局:======")print("hospital_id",debug['hospital_id'])print("doc_name",debug['doc_name'])print("doc_id",debug['doc_id'])print("hos_id",debug['hos_id'])print("sch_date", debug['sch_date'])if r.json()['code']==1:print("获取信息成功!下一步获取预约人信息")tmp_hos_id=str(debug['hos_id'])yuyue(tmp_hos_id)else:print("失败!!!")def cunhuo(tttt):tmo=str(tttt)print("接收到传参数据",tmo)host = "https://newdytapi.ynhdkc.com/index/patient/2807231?hos_id="+tmo# 其他医院请更改871958 华山871958params = {}headers = {"Host": "newdytapi.ynhdkc.com",'Connection': 'keep-alive',"Accept": "application/json, text/plain, */*","User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Authorization": Authorization,"x-uuid": x_uuid,"Origin": "https://appv2.ynhdkc.com","X-Requested-With": "com.tencent.mm","Sec-Fetch-Site": "same-site","Sec-Fetch-Mode": "cors","Sec-Fetch-Dest": "empty","Referer": "https://appv2.ynhdkc.com/","Accept-Encoding": "gzip, deflate","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"}cookies = {"acw_tc": acw_tc}print(host)r = requests.get(host, data=params, headers=headers, cookies=cookies)zate = r.json()['msg']print(zate)def yuyue(hos_id):tmo=str(hos_id)print("接收到传参数据",tmo)host = "https://newdytapi.ynhdkc.com/index/patient/2807231?hos_id="+tmo# 其他医院请更改871958 华山871958params = {}headers = {"Host": "newdytapi.ynhdkc.com",'Connection': 'keep-alive',"Accept": "application/json, text/plain, */*","User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat","Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Authorization": Authorization,"x-uuid": x_uuid,"Origin": "https://appv2.ynhdkc.com","X-Requested-With": "com.tencent.mm","Sec-Fetch-Site": "same-site","Sec-Fetch-Mode": "cors","Sec-Fetch-Dest": "empty","Referer": "https://appv2.ynhdkc.com/","Accept-Encoding": "gzip, deflate","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"}cookies = {"acw_tc": acw_tc}print(host)r = requests.get(host, data=params, headers=headers, cookies=cookies)zate = r.json()['msg']print(zate)gguide=r.json()['data'][0]print("pat_id",gguide['pat_id'])print("user_id",gguide['user_id'])print("=====存入全局====")global user_id, pat_iduser_id = gguide['user_id']pat_id = gguide['pat_id']print("=====存入全局====")print("预约人姓名",gguide['patient_name'])print("开始获取疫苗今日信息")yimiao_data()
def yimiao_data():print("======正在抢====")hos_cede_tt=str(hos_code)dep_id_tt = str(dep_id)doc_id_tt = str(doc_id)pat_id_tt = str(pat_id)user_id_tt = str(user_id)# print("hos_code", hos_cede_tt)# print("dep_id", dep_id_tt)# print("doc_id", doc_id_tt)# print("pat_id", pat_id_tt)# print("user_id", user_id_tt)print("数据预览")# 需要xxuid cookiehost = "https://newdytapi.ynhdkc.com/index/schedule?hos_code="+hos_cede_tt+"&dep_id="+dep_id_tt+"&doc_id="+doc_id_tt+"&from_date="+from_date+"&end_date="+end_date+"®_date="+reg_data+"&hyid=&vip=0"params = {}headers = {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8","Host": "newdytapi.ynhdkc.com","User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat","Accept": "application/json, text/plain, */*","Authorization": Authorization,"x-uuid": x_uuid,"Origin": "https://appv2.ynhdkc.com","X-Requested-With": "com.tencent.mm","Sec-Fetch-Site": "same-site","Sec-Fetch-Mode": "cors","Sec-Fetch-Dest": "empty","Referer": "https://appv2.ynhdkc.com/","Accept-Encoding": "gzip, deflate","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"}cookies = {"acw_tc": acw_tc}print(host)r = requests.get(host, data=params, headers=headers, cookies=cookies)code = r.json()['data']# 昆明市妇幼保健院(华山西路院区 疫苗)print("当前所选择医院疫苗剩余:")# print(code)a = 0for sch_date1 in code:if sch_date1['src_num'] > 0:print("可以抢_次数+1")a=a+1else:print("不可以抢")print("总可抢数据次数:",a)sjs = random.randint(0, a)print("随机数",sjs)code1 = r.json()['data']aa = 0for sch_date in code1:aa=aa+1print("日期:", sch_date['sch_date'], "剩余预约数量:", sch_date['src_num'])if aa==sjs:print("可以抢")# print("schedule_id",sch_date['schedule_id'])# print("sch_date",sch_date['sch_date'])# print("time_type", sch_date['time_type'])tmp_1 = sch_date['schedule_id']tmp_2 = sch_date['sch_date']tmp_3 = sch_date['time_type']qiang(tmp_1, tmp_2, tmp_3)# 跳转到抢 疫苗的qiang函数else:print("不可以抢")def qiang(schedule_id,sch_date,time_type):print("======正在抢疫苗====")hos_code_q=str(hos_code)dep_id_q = str(dep_id)doc_id_q = str(doc_id)pat_id_q = str(pat_id)user_id_q = str(user_id)schedule_id_q = str(schedule_id)sch_date_q = str(sch_date)# sch_date_q=datetime.date(sch_date_q)print(sch_date_q)# sch_date_q = datetime.datetime.strptime(sch_date_q, '%Y-%m-%d').date()time_type_q = str(time_type)url = "https://dytapi.ynhdkc.com/v1/appoint?hos_code="+hos_code_q+"&dep_id="+dep_id_q+"&doc_id="+doc_id_q+"&pat_id="+pat_id_q+"&user_id="+user_id_q+"&schedule_id="+schedule_id_q+"&cate_name="body = {"doc_name": "重组带状疱疹疫苗(CHO细胞)","hos_name": "昆明市妇幼保健院(华山西路院区 疫苗)","hos_code": "871958","dep_name": "疫苗接种预约","level_name": "","dep_id": dep_id_q,"doc_id": doc_id_q,"pat_id": pat_id_q,"schedule_id": schedule_id_q,"jz_card": "","sch_date": sch_date_q,"time_type": time_type_q,"info": "","ghf": 0,"zlf": 0,"zjf": 0,"jz_start_time": 0,"amt": 0,"jz_card_type": 0,"wechat_login": "dytminiapp"}headers = {'Host':'dytapi.ynhdkc.com','Connection': 'keep-alive','Content-Length': '415','Accept': 'application/json, text/plain, */*','x-uuid': x_uuid,'Content-Type': 'application/json;charset=UTF-8','Origin': 'https://appv2.ynhdkc.com','X-Requested-With': 'com.tencent.mm','Sec-Fetch-Site': 'same-site',# 'User-Agent':'Mozilla/5.0 (Linux; Android 9; V1814T Build/PKQ1.180819.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3117 MMWEBSDK/20210601 Mobile Safari/537.36 MMWEBID/9644 MicroMessenger/8.0.11.1980(0x28000B3B) Process/appbrand0 WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 miniProgram','Sec-Fetch-Mode': 'cors','Sec-Fetch-Dest': 'empty','Referer': 'https://appv2.ynhdkc.com/','Accept-Encoding': 'gzip, deflate',"Authorization": Authorization,"acw_tc": acw_tc,'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7'}
#cookies可以携带在headerprint(url)# data = json.dumps(body)print("数据压缩")# print(data)response = requests.post(url, json=body, headers=headers)# 也可以直接将data字段换成json字段,2.4.3版本之后支持# response = requests.post(url, json = body, headers = headers)# 返回信息print (response.text)# 返回响应头print (response.status_code)def timer(n):while True:cunhuo(871958) # 获取用户信time.sleep(n)if __name__ == '__main__':dlogin()# timer(10) # 存活# print("dep_id:", dep_id)# print("doc_id:", doc_id)# print("pat_id:", pat_id)