本技能提供中国主要城市过敏指数(UPI)的实时查询能力,接入华风爱科官方 API,
并生成基于 ECharts 的交互式热力地图,通过颜色深浅直观展示各地过敏风险等级。
> 核心优势:当日缓存 + 智能限速(≤4次/秒),首次拉取全量数据,后续秒级响应。
当用户询问花粉/过敏相关问题时,运行以下命令获取数据:
python scripts/fetch_pollen.py --source weathercn --city <城市名>
示例:
python scripts/fetch_pollen.py --source weathercn --city 北京 — 查询北京过敏指数
python scripts/fetch_pollen.py --source weathercn --city 上海 — 查询上海过敏指数
python scripts/fetch_pollen.py --source weathercn — 生成全国过敏指数地图(默认行为)
生成带颜色深浅标注的交互式热力地图:
python scripts/fetch_pollen.py --source weathercn -o <输出路径>.html
生成的 HTML 文件为独立文件,可直接在浏览器中打开,包含:
以结构化格式导出所有城市过敏指数数据:
python scripts/fetch_pollen.py --source weathercn --json
python scripts/fetch_pollen.py --list-cities
| 等级 | 指数值 | 颜色 | 含义 | 建议 |
|------|--------|------|------|------|
| 极低 | 1 | 🟢 绿色 | 几乎无影响 | 适宜户外活动 |
| 低 | 2 | 🟢 浅绿 | 影响较小 | 敏感人群注意防护 |
| 中等 | 3 | 🟡 黄色 | 有一定诱发风险 | 减少户外活动 |
| 易发 | 4 | 🟠 橙色 | 较易诱发过敏 | 避免外出 |
| 极易发 | 5 | 🔴 红色 | 极易诱发过敏 | 穿长衣+戴口罩+眼镜 |
以清晰的结构化文本呈现:
📍 [城市名] 过敏指数监测报告
━━━━━━━━━━━━━━━━━━━━━━━━━━━
过敏指数: UPI X / 5
等级: [等级名称]
建议措施: [对应建议]
更新时间: [时间]
━━━━━━━━━━━━━━━━━━━━━━━━━━━
requests(pip install requests)
--weathercn-key YOUR_KEY
WEATHERCN_API_KEY=YOUR_KEY
.weathercn_key(与脚本同目录)
references/api-guide.md
CITY_COORDS)
共 1 个版本