thekestrel has asked for the wisdom of the Perl Monks concerning the following question:
<html> <body> <table align="center"> <tr><td>Name</td><td>Blah</td></tr> <tr><td>bill</td><td>fdagdfg</td></tr> <tr><td>ted</td><td>sdfsdf</td></tr> </table> </body> </html>
#!/usr/bin/perl use warnings; use strict; use HTML::TableExtract; #my $te = HTML::TableExtract->new ( depth => 1, count => 2 ); my $te = HTML::TableExtract->new ( attribs => { align => 'center' } ); print "Start\n"; my $data; { local( $/, *FILE); open FILE, "blah.html" or die "Could not open file , $!\n"; $data = <FILE>; close (FILE); } print $data; $te->parse($data); print "table stuff:\n"; foreach my $ts ( $te->tables ) { print "Table\n"; foreach my $row ( $ts->rows ) { print "R ", join(',', @$row), "\n"; } }
|
---|