mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
Update other_than.py
This commit is contained in:
parent
71f860a500
commit
58957cdf44
@ -39,32 +39,35 @@ async def get_other_data(place: str) -> Optional[str]:
|
||||
return None
|
||||
find_data = re.compile(r"varallData=(.*?);</script>")
|
||||
sum_ = re.findall(find_data, html)[0]
|
||||
sum_ = json.loads(sum_)
|
||||
other_country = sum_["yiqing_v2"]["dataList"][29]["child"]
|
||||
for country in other_country:
|
||||
if place == country["name2"]:
|
||||
return (
|
||||
f"{place} 疫情数据:\n"
|
||||
"——————————————\n"
|
||||
f"新增病例:{intcomma(country['quezhen_add'])}\n"
|
||||
f"现有确诊:{intcomma(country['quezhen_xianyou'])}\n"
|
||||
f"累计确诊:{intcomma(country['quezhen'])}\n"
|
||||
f"累计治愈:{intcomma(country['zhiyu'])}\n"
|
||||
f"死亡:{intcomma(country['siwang'])}\n"
|
||||
"——————————————"
|
||||
# f"更新时间:{country['sys_publishDateTime']}"
|
||||
# 时间无法精确到分钟,网页用了js我暂时找不到
|
||||
)
|
||||
else:
|
||||
for city in country["child"]:
|
||||
if place == city["name3"]:
|
||||
return (
|
||||
f"{place} 疫情数据:\n"
|
||||
"——————————————\n"
|
||||
f"新增病例:{intcomma(city['quezhen_add'])}\n"
|
||||
f"累计确诊:{intcomma(city['quezhen'])}\n"
|
||||
f"累计治愈:{intcomma(city['zhiyu'])}\n"
|
||||
f"死亡:{intcomma(city['siwang'])}\n"
|
||||
"——————————————"
|
||||
)
|
||||
try:
|
||||
sum_ = json.loads(sum_)
|
||||
other_country = sum_["yiqing_v2"]["dataList"][29]["child"]
|
||||
for country in other_country:
|
||||
if place == country["name2"]:
|
||||
return (
|
||||
f"{place} 疫情数据:\n"
|
||||
"——————————————\n"
|
||||
f"新增病例:{intcomma(country['quezhen_add'])}\n"
|
||||
f"现有确诊:{intcomma(country['quezhen_xianyou'])}\n"
|
||||
f"累计确诊:{intcomma(country['quezhen'])}\n"
|
||||
f"累计治愈:{intcomma(country['zhiyu'])}\n"
|
||||
f"死亡:{intcomma(country['siwang'])}\n"
|
||||
"——————————————"
|
||||
# f"更新时间:{country['sys_publishDateTime']}"
|
||||
# 时间无法精确到分钟,网页用了js我暂时找不到
|
||||
)
|
||||
else:
|
||||
for city in country["child"]:
|
||||
if place == city["name3"]:
|
||||
return (
|
||||
f"{place} 疫情数据:\n"
|
||||
"——————————————\n"
|
||||
f"新增病例:{intcomma(city['quezhen_add'])}\n"
|
||||
f"累计确诊:{intcomma(city['quezhen'])}\n"
|
||||
f"累计治愈:{intcomma(city['zhiyu'])}\n"
|
||||
f"死亡:{intcomma(city['siwang'])}\n"
|
||||
"——————————————"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"疫情查询发生错误 {type(e)}:{e}")
|
||||
return None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user