use Encode; use WWW::Mechanize; use Web::Scraper; use JSON; my $baseUrl = 'http://www.seven-ripe.sakura.ne.jp/nml/index.php?category=%s'; my $mech = WWW::Mechanize->new(autocheck=>1); my $json = JSON->new(); my $pageResult; my @tours = (); my $contentParse = scraper { process '//div[@id="contents"]/div[@id="main"]/h2[1]', 'tour_name'=>"TEXT"; process '//div[@id="contents"]/div[@id="main"]/dl[@class="information"]/dd[1]/div', 'date' =>"TEXT"; process '//div[@id="contents"]/div[@id="main"]/dl[@class="information"]/dd[2]/div', 'place' =>"TEXT"; process '//div[@id="contents"]/div[@id="main"]/dl[@class="information"]/dd[3]/div', 'venue' =>"TEXT"; process '//div[@id="contents"]/div[@id="main"]/ol[1]//li', 'setlist[]' => "TEXT"; process '//div[@id="contents"]/div[@id="main"]/ol[2]//li', 'encorelist[]' => "TEXT"; process '//div[@id="contents"]/div[@id="main"]/ol[3]//li', 'wencorelist[]' => "TEXT"; }; $mech->agent_alias("Windows Mozilla"); foreach my $category ( 1 .. 148 ) { $mech->get( sprintf($baseUrl,$category) ); $pageResult = $contentParse->scrape( $mech->content ); push(@tours, $pageResult); } $json->pretty(); print encode('utf-8',$json->encode(\@tours));