Google 検索で、「天気 水戸」とか検索すると、天気予報を表示してくれるあいつ。

ソースコードは、例によってGitHub

使い方も超簡単。

モジュールのインストール

$ git clone git://github.com/eru/WWW-Google-WeatherJP.git
$ cd WWW-Google-WeatherJP
$ perl Makefile.PL
$ make
$ make test
$ sudo make install

サンプル

use warnings;
use strict;
use WWW::Google::WeatherJP;
use Encode;
my $weather = WWW::Google::WeatherJP->new();
$weather->get("水戸");
if($weather->success) {
print encode('utf-8', $weather->place) . "\n";
print encode('utf-8', $weather->now) . "\n";
print encode('utf-8', $weather->today) . "\n";
print encode('utf-8', $weather->tomorrow) . "\n";
print encode('utf-8', $weather->next_tomorrow) . "\n";
} else {
print "failed\n";
}

実行結果

茨城県水戸市
曇り 12°C 風: 北 2 m/s 湿度: 88%
大体晴れ 13°C / 8°C
雨の可能性 17°C / 13°C
大体晴れ 17°C / 4°C

こんな感じ。

Tagged with:
 

コメントを残す

メールアドレスが公開されることはありません。

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>