通过中央气象台(nmc.cn)公开 API 查询全国 2,529 个气象站点的天气数据,支持输入城市名即可查询,无需记住站点代码。
任何与中国城市天气相关的提问,包括但不限于:
# 查询指定城市天气(默认全部信息)
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py "城市名"
# 仅查实时天气
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py "北京" --type real
# 仅查7天预报
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py "上海" --type forecast
# 仅查逐小时数据
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py "深圳" --type hourly
# 直接使用站点ID查询(高级用法)
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py --stationid Wqsps
# 模糊搜索城市名,查看匹配的站点
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py --search "丽江"
# 强制更新站点索引(一般不需要,索引会自动维护)
python3 /home/z/my-project/skills/china-weather/scripts/fetch_weather.py --build-index
脚本内置了智能城市名匹配:
共 1 个版本