Perl で CDTV のランキングを Get するモジュールとしては,WWW-CDTV がありますが,とりあえず Web::Scraper で書いてみた.
#!/opt/local/bin/perl use strict; use warnings; use Web::Scraper; use URI; use YAML::Syck; binmode STDOUT => ':utf8'; my $ranking = scraper { process '//tr[@class="tbg1" or @class="tbg2"]', 'records[]' => scraper { process '//th', 'rank' => 'TEXT'; process '//td[1]/img', 'status' => '@alt'; process '//td[2]', 'title' => 'TEXT'; process '//td[3]', 'artist' => 'TEXT'; }; result 'records'; }->scrape( URI->new( "http://www.tbs.co.jp/cdtv/cddb/thisweek.html" ) ); printf "%3d %s\n %s\n", $_->{rank}, $_->{title}, $_->{artist} for @{$ranking}[0 .. 9];
$ ./cdtv.pl 1 ONE DROP KAT-TUN 2 泪のムコウ ステレオポニー 3 愛のままで… 秋元順子 4 浪曲一代 氷川きよし 5 1,2,3 for 5 ゴスペラーズ 6 鏡花水月 The SHIGOTONIN 7 WAO! ユニコーン 8 コルテオ〜行列〜/HALFWAY Salyu 9 歩み GReeeeN 10 約束 KinKi Kids