关于 weather
用于查询当前天气、今日天气和预报的天气技能,主要使用 wttr.in,并以 Open-Meteo JSON 接口作为备用。适合无需 API 密钥获取天气信息的用户或 Agent。
主要功能
- 01查询当前天气与预报
- 02自定义天气输出格式
- 03支持公制与美制单位
- 04获取天气 PNG 图片
- 05备用 Open-Meteo JSON 接口
适用场景
- 01查询某地当前天气
- 02查看今日天气或完整预报
- 03以编程方式获取天气数据
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hkuds/ nanobot --skill weather安装后在 Claude Code 中输入/weather确认已加载。
详细介绍
天气
两个免费服务,无需 API 密钥。
wttr.in(首选)
选择与用户需求范围匹配的一个请求。当今日或预报请求已包含当前天气状况时,不要单独再获取。
平台说明:
- 在 Windows PowerShell 上,使用
curl.exe;直接使用curl可能会解析为Invoke-WebRequest。 - 在 macOS 和 Linux 上,使用
curl。
仅当前天气状况:
curl -s "https://wttr.in/London?format=3"
# Output: London: ⛅️ +8°C
自定义当前天气状况格式:
curl -s "https://wttr.in/London?format=%l:+%c+%t+%h+%w"
# Output: London: ⛅️ +8°C 71% ↙5km/h
今日天气,包括当前天气状况(关于今日天气的问题请使用此单一请求):
curl -s "https://wttr.in/London?1&m"
完整预报:
curl -s "https://wttr.in/London?T&m"
在 Windows PowerShell 上,将上述命令中的 curl 替换为 curl.exe。
格式代码:%c 天气状况 · %t 温度 · %h 湿度 · %w 风 · %l 位置 · %m 月相
提示:
- 对空格进行 URL 编码:
wttr.in/New+York - 机场代码:
wttr.in/JFK - 单位:
?m(公制)?u(美制) - 仅今日:
?1· 仅当前:?0 - PNG(macOS/Linux):
curl -s "https://wttr.in/Berlin.png" -o weather.png - PNG(Windows PowerShell):
curl.exe -s "https://wttr.in/Berlin.png" -o weather.png
Open-Meteo(备用,JSON)
免费,无需密钥,适合程序化使用:
curl -s "https://api.open-meteo.com/v1/forecast?latitude=51.5&longitude=-0.12¤t_weather=true"
查找城市的坐标,然后查询。返回包含温度、风速、天气代码的 JSON。
评论
支持 Markdown