wttr.in 如何在终端下用cURL获取天气信息

wttr.in 是终端下的天气预报小程序,它是Wego的前端。我们可以借助cURL和wttr.in在终端下获取天气信息。wttr.in 默认会自动检测你所在的地理位置。如果检测失败,它允许你以多种方式来指定地理位置。可以用城市名,3位机场代码,或邮编来指定。它也能拉取一个域名或IP地位的天气信息。

wttr.in可以提供3天以内的天气预报,显示月相,并同时支持国际单位制(SI)与美国单位制(USCS)。wttr.in在底层使用WorldWeatherOnline服务来获取信息。但Wego最近放弃了WorldWeatherOnline,转而使用forecast.io。

使用 wttr.in

使用wttr.in的唯一条件是安装curl。Debian/Ubuntu/Linux Mint等发行版用户使用下面的命令安装curl。

sudo apt-get install curl

运行下面的命令获取当地的天气信息。

curl wttr.in

wttr.in 如何在终端下用cURL获取天气信息

发现wttr.in并不能准确地检测地理位置。我们可以用以下方法来指定地理位置。

城市名:

curl wttr.in/"Shenzhen"

机场的国际3位代码。lax是洛杉矶国际机场。

curl wttr.in/lax

查看域名所在地理位置的天气。

curl wttr.in/@www.linuxdashen.com

wttr.in 如何在终端下用cURL获取天气信息

查看月相。

curl wttr.in/moon

wttr.in 如何在终端下用cURL获取天气信息

查看帮助信息。

curl wttr.in/:help
为这篇文章评分
[Total: 2 Average: 3]

Leave a Reply

Your email address will not be published.

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here