15
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シェルで今日の天気予報表示

Last updated at Posted at 2013-10-05
  • livedoor天気予報が提供するWeather HacksのAPIを利用する。
  • 結果はJSONで返ってくるのでjqコマンドに渡す。jqbrew intall jqなどしてインストール
$ curl -s http://weather.livedoor.com/forecast/webservice/json/v1\?city\=XXXXXX | jq -r '.forecasts[] | select(.dateLabel == "今日").telop'

XXXXXXに地域IDを入力。地域IDはここから確認できる。

大阪(地域ID:270000)の天気予報を表示してみる

$ curl -s http://weather.livedoor.com/forecast/webservice/json/v1\?city\=270000 | jq -r '.forecasts[] | select(.dateLabel == "今日").telop'
曇り

API仕様を見ると、もちろん今日の天気以外にも取得できるので、色々と応用できそう。

15
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?