├── test.txt ├── README.md └── main.py /test.txt: -------------------------------------------------------------------------------- 1 | wxtoken:537ff13f3c31b67df7aa94db9395ac3f_0116b6049953d14f81d0fbdf5f18c7d8 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # -HPV- 2 | 每半分钟检索一次约苗公众号,并打印有苗的医院以及疫苗数量,有周六周天的疫苗时弹框提醒,现阶段仅支持济南当地,若有其他地区的用户,请自行修改经纬度 3 | 4 | test.txt 文件中的token需用fiddler等抓包工具,抓取约苗公众号的请求,得到token并填写到文件中,不然会提示报错,报错原因是用户登录超时 5 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import time 4 | import datetime 5 | import tkinter 6 | import tkinter.messagebox 7 | 8 | def weekChange(week): 9 | if week == 1: 10 | return '周一' 11 | elif week == 2: 12 | return '周二' 13 | elif week == 3: 14 | return '周三' 15 | elif week == 4: 16 | return '周四' 17 | elif week == 5: 18 | return '周五' 19 | elif week == 6: 20 | return '周六' 21 | elif week == 7: 22 | return '周日' 23 | 24 | 25 | f = open('test.txt') 26 | tk = f.readline() 27 | cookie = 'UM_distinctid=17700ac42240-0b33a11b9e4d68-20582e26-1fa400-17700ac42295b4; _xzkj_= ' + tk + '; _xxhm_=%7B%22address%22%3A%22%E5%AE%89%E4%B9%90%E9%95%87%E5%B0%8F%E5%8C%BA%22%2C%22awardPoints%22%3A0%2C%22birthday%22%3A750096000000%2C%22createTime%22%3A1589854819000%2C%22headerImg%22%3A%22http%3A%2F%2Fthirdwx.qlogo.cn%2Fmmopen%2FajNVdqHZLLD2pMRmmYaQaLBDChem66aoN9svAnicpZPDx2jP21aPaPtCHBljnfwxSu9Gwia5NBAUH1tj7xa4FbVA%2F132%22%2C%22id%22%3A5547063%2C%22idCardNo%22%3A%2237010519931009501X%22%2C%22isRegisterHistory%22%3A0%2C%22latitude%22%3A36.650768%2C%22longitude%22%3A117.118713%2C%22mobile%22%3A%2215066121027%22%2C%22modifyTime%22%3A1606914586000%2C%22name%22%3A%22%E8%B0%A2%E8%B6%85%22%2C%22nickName%22%3A%22%E1%83%A6Mr%E3%80%86%C2%B0%E8%B0%A2%22%2C%22openId%22%3A%22oWzsq5_KzifgG9-xnWt65oBLhRcc%22%2C%22regionCode%22%3A%22370105%22%2C%22registerTime%22%3A1606914586000%2C%22sex%22%3A1%2C%22source%22%3A1%2C%22uFrom%22%3A%22depa_vacc_detail%22%2C%22unionid%22%3A%22oiGJM6OGsfxJNteI_rfIzkf3Jh7k%22%2C%22wxSubscribed%22%3A1%2C%22yn%22%3A1%7D; CNZZDATA1261985103=596264046-1610954889-%7C1611020154' 28 | 29 | headers = { 30 | 'Cookie': cookie, 31 | 'tk': tk 32 | } 33 | 34 | param = {'offset': '0', 35 | 'limit': '1000', 36 | 'name': '', 37 | 'regionCode': 3701, 38 | 'isOpen': 1, 39 | 'longitude': '117.11876678466797', 40 | 'latitude': '36.650978088378906', 41 | 'sortType': 1, 42 | 'vaccineCode': '', 43 | 'customId': 2} # customId等于2是四价 等于52是两价 44 | 45 | 46 | def request(): 47 | while True: 48 | respone = requests.get('http://wx.scmttec.com/base/department/getDepartments.do', headers=headers, params=param) 49 | textJson = json.loads(respone.text) 50 | rowsList = textJson.get('data').get('rows') 51 | 52 | haveList = [] 53 | for rowItem in rowsList: 54 | total = rowItem.get('total') 55 | if(total>0): 56 | haveList.append(rowItem) 57 | 58 | print('总共查询到' + str(len(rowsList)) + '家医院,其中有苗的医院有' + str(len(haveList)) + '家') 59 | for haveItem in haveList: 60 | name = haveItem.get('name') 61 | total = haveItem.get('total') 62 | print(name + '共有疫苗:' + str(total) + '只') 63 | 64 | depaCode = haveItem.get('code') 65 | vaccCode = haveItem.get('vaccineCode') 66 | vaccIndex = 3 67 | subsribeDate = time.strftime("%Y-%m-%d", time.localtime()) 68 | departmentVaccineId = haveItem.get('depaVaccId') 69 | linkmanId = '7824969' 70 | 71 | workDayParam = { 72 | 'depaCode': depaCode, 73 | 'vaccCode': vaccCode, 74 | 'vaccIndex': vaccIndex, 75 | 'departmentVaccineId': departmentVaccineId, 76 | 'linkmanId': linkmanId 77 | } 78 | 79 | # {"code":"0000","data":{"dateList":["2021-01-20","2021-01-21","2021-01-22","2021-01-23","2021-01-24","2021-01-25","2021-01-26"],"subscribeDays":7},"notOk":false,"ok":true} 80 | workDayRespone = requests.get('https://wx.scmttec.com/order/subscribe/workDays.do', headers=headers, params=workDayParam) 81 | workDayJson = json.loads(workDayRespone.text) 82 | workDayData = workDayJson.get('data') 83 | if('dateList' in workDayData) : 84 | workDayList = workDayData.get('dateList') 85 | workDayStr = ','.join(workDayList) 86 | workDayStr = workDayStr.replace('-', '') 87 | 88 | subscribeAmountParam = { 89 | 'depaCode': depaCode, 90 | 'vaccCode': vaccCode, 91 | 'vaccIndex': vaccIndex, 92 | 'departmentVaccineId': departmentVaccineId, 93 | 'days': workDayStr 94 | } 95 | # {"code":"0000","data":[{"maxSub":198,"day":"20210120"},{"maxSub":189,"day":"20210121"},{"maxSub":185,"day":"20210122"},{"maxSub":176,"day":"20210123"},{"maxSub":187,"day":"20210124"},{"maxSub":194,"day":"20210125"},{"maxSub":200,"day":"20210126"}],"notOk":false,"ok":true} 96 | subscribeAmountRespone = requests.get('https://wx.scmttec.com/order/subscribe/findSubscribeAmountByDays.do', headers=headers, params=subscribeAmountParam) 97 | 98 | subscribeAmountJson = json.loads(subscribeAmountRespone.text) 99 | dataList = subscribeAmountJson.get('data') 100 | for dataItem in dataList: 101 | maxSub = dataItem.get('maxSub') 102 | day = dataItem.get('day') 103 | workDayDate = datetime.datetime.strptime(day, '%Y%m%d').date() 104 | week = workDayDate.isoweekday() 105 | 106 | if(week == 6 or week == 7): 107 | weekStr = weekChange(week) 108 | tkinter.messagebox.showinfo('提示', name + ',' + day + '(' + weekStr + ')' + '有疫苗') 109 | else: 110 | continue 111 | time.sleep(2) 112 | print('---------------' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '-------------') 113 | time.sleep(30) 114 | 115 | try: 116 | request() 117 | 118 | except TypeError: 119 | tkinter.messagebox.showerror('错误', '报错了') --------------------------------------------------------------------------------