代码拉取完成,页面将自动刷新
同步操作将从 Thund1r/daily-info 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''
Author: Thund1r thund1r@foxmail.com
Date: 2022-09-22 14:31:16
LastEditTime: 2022-10-08 22:12:16
Description: 疫情数据
Copyright (c) 2022 by Thund1r thund1r@foxmail.com, All Rights Reserved.
'''
# -*- coding: utf8 -*-
import config
import requests
yqcity_list = config.get_list("yqcity")
# 获取城市疫情数据
def get_yq(city_name):
try:
res = requests.get(
f'https://covid.myquark.cn/quark/covid/data/index_data?format=json&method=Huoshenshan.ncov2022&city={city_name}').json()['data']
if len(res['cityData']) == 0:
res['cityData'] = res['provinceData']
yq_res_list = [
{"desc": "🤒 新增确诊/无症状",
"detail": str(res['cityData']["sure_new_loc"])+"/" + str(res['cityData']["sure_new_hid"])},
{"desc": "😷 现有确诊",
"detail": res['cityData']["present"]},
{"desc": "⛔️ 中/高风险区",
"detail": str(res['cityData']["danger"]["1"]) + "/" + str(res['cityData']["danger"]["2"])}
]
yq_tip_list = []
yq_tip_list.append(f'🏥 {city_name}疫情({(res["time"][4:])})')
for item in yq_res_list:
yq_tip_list.append(item['desc'] + ":" + str(item['detail']))
yq_tip = '\n'.join(yq_tip_list)
return yq_tip
except Exception as e:
print("获取疫情数据错误:", e)
return None
# 获取所有疫情数据
def get_map_yq():
if yqcity_list:
map_yq_tip = None
yq_list = list(map(get_yq, yqcity_list))
yq_list = list(filter(None, yq_list))
if yq_list:
map_yq_tip = "\n".join(yq_list)
return map_yq_tip
else:
print("没有填写疫情数据城市")
return None
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。