Web::Scraper使ってみた
すごい。
#!/usr/bin/perl use Web::Scraper; use URI; my $scraper = scraper { process '#pager-top a[rel="prev"]', 'prev' => '@href'; process '#pager-top a[rel="next"]', 'next' => '@href'; process 'div.section h3 a', 'url' => '@href'; process 'div.section h3', 'title' => 'TEXT'; process 'div.section', 'entry' => 'TEXT'; }; my $uri = new URI('http://d.hatena.ne.jp/mir/20080513/p1'); my $res = $scraper->scrape($uri); print "$res->{prev}\n"; print "$res->{next}\n"; print "$res->{title}\n"; #print "$res->{entry}\n";
とりあえずこんな感じでHatena::Diaryのデータも扱える。