use strict;
use LWP::UserAgent;
use HTML::TreeBuilder;
my $ua = LWP::UserAgent->new;
my $page = $ua->LWP::UserAgent::get("http://www.databasefootball.com/boxscores/scheduleyear.htm?yr=1985&lg=nfl",
'User-Agent'=>'Mozilla/5.0');
my $tree = HTML::TreeBuilder->new;
$tree->parse_content($page->decoded_content);
#$tree->dump;
foreach my $table ($tree->look_down('_tag', 'table')) {
print "###Table###\n";
foreach my $row ($table->look_down('_tag', 'tr', sub { $_[0]->look_up('_tag', 'table') == $table; })) {
if ($row->as_text =~ / at /) {
my $c = 0;
foreach my $col ($row->look_down('_tag', qr/^t[dh]$/, sub { $_[0]->look_up('_tag', 'tr') == $row; })) {
if ($c++) { print " "; }
printf "%s", $col->as_text;
if ($col->look_down('href', qr/./)) {
printf " [%s]", $col->look_down('href', qr/./)->attr('href');
}
}
print "\n";
}
else {
printf "%s\n", $row->as_text;
}
}
}
exit;