Created
May 14, 2012 17:27
-
-
Save kenjiskywalker/2695188 to your computer and use it in GitHub Desktop.
JSPORTSのヤツにチャリの項目追加した
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Web::Scraper; | |
use URI; | |
use Web::Scraper; | |
use HTML::TreeBuilder; | |
use Data::Dumper; | |
use utf8; | |
binmode(STDOUT,"utf8"); | |
my $scraper_td = scraper{ | |
process 'td', 'schedule[]'=>'TEXT'; | |
# return data; | |
result 'schedule'; | |
}; | |
my $scraper_dl = scraper{ | |
process 'li>dl', 'schedule[]'=>'TEXT'; | |
# return data; | |
result 'schedule'; | |
}; | |
my $football = new URI('http://www.jsports.co.jp/football/'); | |
my $cycle = new URI('http://www.jsports.co.jp/cycle/'); | |
my $res_foot = $scraper_td->scrape($football); | |
my $res_cyle = $scraper_dl->scrape($cycle); | |
print Dumper $res_cyle; | |
my $foot_sche = ''; | |
my $cycle_sche = ''; | |
for my $data (@$res_foot){ | |
$foot_sche = $foot_sche.$data."\n"; | |
} | |
for my $data (@$res_cyle){ | |
$cycle_sche = $cycle_sche.$data."\n"; | |
} | |
get '/jsports' => sub { | |
my $self = shift; | |
$self->stash('foot_schedule' => $foot_sche); | |
$self->stash('cycle_schedule' => $cycle_sche); | |
$self->render(); | |
} => 'index'; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<html> | |
<head> | |
<title>JSPORTS 番組表</title> | |
</head> | |
<body> | |
<pre> | |
<br><h2> FootBall Schedules</h2> | |
================================================================= | |
<br><%= $foot_schedule %> | |
================================================================= | |
<br><h2> Cycle Schedules</h2> | |
================================================================= | |
<br><%= $cycle_schedule %> | |
================================================================= | |
</pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment