お天気Webサービスいじり
Weather Hacks
お天気Webサービス仕様 - Weather Hacks
REST的実装になってる.早速Perlで叩いてみた.すっごい手抜き実装ですけどー.
use strict; use LWP::UserAgent; use URI; use XML::Simple 'XMLin'; use Template; my $uri = URI->new('http://weather.livedoor.com/forecast/webservice/rest/v1'); $uri->query_form(city => 70, day => 'today'); # 70 = 横浜市 my $xml = XMLin( LWP::UserAgent->new->get($uri)->content ); Template->new->process(\*DATA, { weather => $xml }); __END__ [% weather.title %]は[% weather.telop %], 最高気温は[% weather.temperature.max.celsius %]度, 最低気温は[% weather.temperature.min.celsius %]度になるでしょう. (予報時間:[% weather.publictime %])
結果はこんな感じ.
神奈川県 横浜 - 今日の天気は晴れ, 最高気温は11度, 最低気温は0度になるでしょう. (予報時間:Thu, 09 Feb 2006 17:00:00 +0900)
本当はWebService::Livedoor::Weatherとか作るのがスマートなんだろうけど,眠いのでここまで.と言っておいて気が付いてみると,かぜぶろさんが作っていた.キャッシュ機能も付いていていい感じ.ところでCacheモジュールって,ppmが無かったような希ガス.