Here's my go (based on examples in the docs)...
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use HTML::TableContentParser;
my $url = q|http://64.144.108.98/history/Allplayersstate.asp?State=AL|
+;
my $mech = WWW::Mechanize->new()
or die "couldn't get Mech object: $!";
$mech->get($url)
or die "couldn't get: $!";
my $html = $mech->content()
or die "content failed: $!";
my $p = HTML::TableContentParser->new();
my $tables = $p->parse($html);
open my $fh, '>', 'tables.txt'
or die "can't open output\n";
for my $t (@$tables) {
for my $r (@{$t->{rows}}) {
print $fh "Row: ";
for my $c (@{$r->{cells}}) {
my $data = $c->{data};
print $fh "[$data] ";
}
print $fh "\n";
}
}
Extract from output:
Row:
[13507]
[4/30/1998]
[<a href="Phistory.asp?Pid=13200">Acoff, Fred</a>]
[1678 (1678)]
[AL]
[<a href="Tall.asp?Tid=785&SBy=LastName+Asc">3/16/1997</a>]
Row:
[71636]
[5/31/2007]
[<a href="Phistory.asp?Pid=56179">Akhtar, Jibran(Brian)</a>]
[152 (152)]
[AL]
[<a href="Tall.asp?Tid=3332&SBy=LastName+Asc">7/8/2006</a>]
Row:
[45757]
[12/31/9999]
[<a href="Phistory.asp?Pid=30169">Alexy, Tom</a>]
[1342 (1475)]
[AL]
[<a href="Tall.asp?Tid=3232&SBy=LastName+Asc">3/25/2006</a>]
Row:
[57249]
[3/31/1991]
[<a href="Phistory.asp?Pid=37455">Alford, Josh</a>]
[594 (594)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
Row:
[57242]
[3/31/1991]
[<a href="Phistory.asp?Pid=37448">Alford, Tom</a>]
[652 (652)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
Row:
[70273]
[3/31/2009]
[<a href="Phistory.asp?Pid=52193">Alter, Torin</a>]
[1289 (1340)]
[AL]
[<a href="Tall.asp?Tid=3356&SBy=LastName+Asc">9/10/2006</a>]
Row:
[3865]
[5/31/1994]
[<a href="Phistory.asp?Pid=3673">Alvey, Clyde Henry</a>]
[1578 (1578)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
Row:
[55518]
[7/31/1990]
[<a href="Phistory.asp?Pid=35871">Ammons, Jermey C.</a>]
[859 (859)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
Row:
[59871]
[4/30/1993]
[<a href="Phistory.asp?Pid=39893">Anderson, Derriel</a>]
[1173 (1173)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
Row:
[57295]
[9/30/1990
[<a href="Phistory.asp?Pid=37497">Ardoin, Jean Louis</a>]
[1567 (1567)]
[AL]
[<a href="Tall.asp?Tid=0&SBy=LastName+Asc"></a>]
|