当前位置:   article > 正文

自动化滇医通

自动化滇医通

###我已经将数据爬取出来###
现在开源集合大家的思路一起研究
(请更换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  华山871958
    params = {


    }
    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_code
        dep_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+"&reg_date="+reg_data+"&other_info=undefined&vip=0"
    # 其他医院请更改871958  华山871958
    params = {

    }
    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_id
    doc_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  华山871958
    params = {

    }
    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  华山871958
    params = {

    }
    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_id
    user_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 cookie
        host = "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+"&reg_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 = 0
        for sch_date1 in code:
            if sch_date1['src_num'] > 0:
                print("可以抢_次数+1")
                a=a+1
            else:
                print("不可以抢")
            print("总可抢数据次数:",a)
        sjs = random.randint(0, a)
        print("随机数",sjs)
        code1 = r.json()['data']
        aa = 0
        for sch_date in code1:
            aa=aa+1
            print("日期:", 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可以携带在header
    print(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)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/672356
推荐阅读
相关标签
  

闽ICP备14008679号