Created
May 1, 2012 00:58
-
-
Save kenjiskywalker/2564073 to your computer and use it in GitHub Desktop.
Mojolicious::Lite::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; | |
# binmode(STDOUT,"utf8"); | |
my $scraper = scraper{ | |
process 'td', 'schedule[]'=>'TEXT'; | |
# return data; | |
result 'schedule'; | |
}; | |
my $uri = new URI('http://www.jsports.co.jp/football/'); | |
my $res = $scraper->scrape($uri); | |
my $sche = ''; | |
for my $data (@$res){ | |
$sche = $sche.$data."\n"; | |
} | |
get '/' => sub { | |
my $self = shift; | |
$self->stash('schedule' => $sche); | |
$self->render(); | |
} => 'index'; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<html> | |
<head> | |
<title>JSPORTS 番組表</title> | |
</head> | |
<body> | |
<pre> | |
<br><h2> FootBall Schedules</h2> | |
================================================================= | |
<br><%= $schedule %> | |
================================================================= | |
</pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment