#!/usr/bin/perl use encoding 'utf-8'; use strict; use warnings; use Encode qw(from_to); use URI; use URI::Escape qw(uri_escape_utf8); use Web::Scraper; use YAML; if ($^O eq 'MSWin32') { binmode(STDERR, ':encoding(shift_jis)'); Encode::from_to($ARGV[0], 'cp932', 'utf-8'); } my $talent = shift || '小島よしお'; my $talent_schedule = scraper { process '//div[@class="find_bl"]/following-sibling::*[1]//td', day => 'TEXT'; process '//div[@class="find_bl"]/following-sibling::*[1]//td/div', 'schedule[]' => scraper { process 'div', media => sub { my $m = $_->attr('class'); $m =~ s/^icon_//g; $m }; process '/div/a', url => '@href'; process '/div/a', title => 'TEXT'; process '/div/node()[1]', timespan => sub { my $s = $_->string_value; $s =~ s/ //; $s =~ s/(^|[^\d])(\d):(\d\d)/0$2:$3/g; my @span = split(/[^\d:]/, $s); \@span; }; }; result qw/day schedule/; }; my $uri = URI->new('http://talent-schedule.jp/'.uri_escape_utf8($talent)); my $oppappi_schedule = $talent_schedule->scrape($uri); warn Dump $oppappi_schedule;