Skip to content

Instantly share code, notes, and snippets.

@kenjiskywalker
Created May 1, 2012 00:58
Show Gist options
  • Save kenjiskywalker/2564073 to your computer and use it in GitHub Desktop.
Save kenjiskywalker/2564073 to your computer and use it in GitHub Desktop.
Mojolicious::Lite::JSPORTS
#!/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