简约版【HPV疫苗实时在线检测】

简约版【HPV疫苗检测】

更新于:2021/08/30
仅用于保存,方便后期完善

# -*- coding: UTF-8 -*-
import datetime
import json
import time

import requests

requests.packages.urllib3.disable_warnings()


def get_city(cid):
    value = []
    url = 'https://wx.scmttec.com/base/region/childRegions.do?parentCode=' + cid
    head = {
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63030522)"
    }
    str = requests.get(url=url, headers=head, verify=False).text
    json_str = json.loads(str)['data']
    for item in json_str:
        value.append(item['value'])
    return (value)


def get_privince():
    dict_cityID = {}
    head = {
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63030522)"}
    url = "https://wx.scmttec.com/base/region/childRegions.do?parentCode="
    str = requests.get(url=url, headers=head, verify=False).text
    json_str = json.loads(str)['data']
    for item in json_str:
        dict_cityID[item['name']] = item['value']
    return dict_cityID


def get_info(city_arr):
    dict_info = {}
    list_ID = []
    for cid in city_arr:
        if cid == '11' or cid == '12' or cid == '50' or cid == '31':  # '北京市': '11', '天津市': '12' '重庆市': '50' '上海市': '31'
            list_ID.append(cid+'01')
        else:
            city = get_city(cid)
            for i in city:
                list_ID.append(i)
    for cid in list_ID:
        url = 'https://wx.scmttec.com/base/department/getDepartments.do'
        data = {
            "customId": "3",
            "isOpen": "1",
            "limit": "100",
            "offset": "0",
            "regionCode": cid,
            "sortType": "1",
        }
        head = {
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63030522)"
        }
        str = requests.post(url=url, headers=head,data=data,verify=False).text
        json_str = json.loads(str)['data']['rows']
        for item in json_str:
            total = item['total']
            if int(total) >= 1:
                name = item['name']
                address = item['address']
                tel = item['tel']
                tips = item['vaccineName']
                dict_info[name] = address+"|"+tel +"|"+tips
    print("--------------------------------------------\n")
    print("-         Time: "+ datetime.datetime.strftime( datetime.datetime.now(),'%Y-%m-%d %H:%M:%S') +"        -")
    for name in dict_info.keys():
        print(name+'   >>>  \t'+dict_info[name])
    print("----------------- Finished -----------------\n")
    print("\n\n\n\n\n\n本次完成,请等待下一次刷新......\n\n")

if __name__ == '__main__':
    dict_cityID = get_privince()
    print(dict_cityID)
    city_id = input("请输入您要检测的省份代号,多个省份用英文逗号隔开,如果全部检测,请输入'all':")
    print('Tips:若输入all可能查询时间较长,请耐心等待。')
    if city_id =='all':
        city_id = ''
        for i in dict_cityID.values():
            city_id = city_id + ","+ i


    print("定时任务开始,每五分钟刷新一次")
    while True:
        city_arr = city_id.split(',')
        get_info(city_arr)
        time.sleep(60*5)


  • 0
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Coder_Xiaopang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值