NAME
Weather::TW - Fetch Taiwan weather data from http://www.cwb.gov.tw/
SYNOPSIS
use Weather::TW;
my $weather = new Weather::TW;
my $xml = $weather->area('Taipei')->xml;
my $json = $weather->json;
my $yaml = $weather->yaml;
my %hash = $weather->hash;
foreach my $area ($weather->area_en){
my $xml = $weather->area($area)->xml
print $xml;
}
use utf8;
$xml = $weather->area('台北')->xml;
# Chinese also works!
DESCRIPTION
This module parse data from http://www.cwb.gov.tw/ (中央氣象局), and generates xml data. In future it may support json and other formats as well.
METHODS
new
-
Create a new
Weather::TW
object. area('$area_name')
-
City name can be either Chinese or English. The returned value is
$self
so you can use it for cascading.$xmlstr = $weather->area('Taipei City')->to_XML;
The available area names are:
台北市 Taipei City 新北市 New Taipei City 台中市 Taichung City 台南市 Tainan City 高雄市 Kaohsiung City 基隆北海岸 Keelung North Coast 桃園 Taoyuan 新竹 Hsinchu 苗栗 Miaoli 彰化 Changhua 南投 Nantou 雲林 Yunlin 嘉義 Chiayi 屏東 Pingtung 恆春半島 Hengchun Peninsula 宜蘭 Yilan 花蓮 Hualien 台東 Taitung 澎湖 Penghu 金門 Kinmen 馬祖 Matsu
area_zh
-
Return area names in Chinese.
@names = $weather->area_zh;
area_en
-
Return area names in English.
@names = $weather->area_en;
xml
-
Return data as xml.
json
-
Return data as json.
json_pretty
-
Pretty json.
yaml
-
Return data as yaml.
hash
-
Return a perl hash object.
%hash = $weather->hash;
SEE ALSO
https://github.com/dryman/Weather-TW
and
AUTHOR
dryman, <idryman@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2011 by dryman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.