davido has asked for the wisdom of the Perl Monks concerning the following question:
I'm attempting to use HTML::TableExtract to grab the contents of a table of data from an HTML source. I'm using the 'headers' method of finding the appropriate table within a nest of several tables. However, I've been unsuccessful so far in getting the following test-script to produce any output at all. This is troubling, since the snippet is almost verbatum taken from the Synopsis provided in the POD for the module in question.
use strict; use warnings; use LWP::Simple; use HTML::TableExtract; #my $page = get( 'http://www.garmin.com/support/download.jsp'); my $raw_html = do { open my $in, '<', 'garmin.htm' or die "Can't open infile: $!\n"; local $/ = undef; <$in>; }; my $te = new HTML::TableExtract( headers => ["Product Name", "Software Version", "Compatible with Versions +", "Date" ] ); $te->parse($raw_html); # Examine all matching tables foreach my $ts ( $te->table_states ) { print "Table (", join(',', $ts->coords), "):\n"; foreach my $row ( $ts->rows ) { print join( ',', @$row ), "\n"; } }
The table I'm trying to grab is found at http://www.garmin.com/support/download.jsp.
This is entirely for personal use, and not really all that important of a script. I already have a working version that uses regexes to pull the appropriate data and notify me if there's been an update to one of the particular devices I'm interested in, and even without that, Garmin has an email notification system in place. But I wanted to see if I could rewrite it using a more robust parser.
Any suggestions on where my snippet is failing to enable the module to find the table I'm searching for would be appreciated.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using HTML::TableExtract
by sacked (Hermit) on Jun 18, 2004 at 16:15 UTC | |
by Roy Johnson (Monsignor) on Jun 18, 2004 at 16:25 UTC | |
|
Re: Using HTML::TableExtract
by mojotoad (Monsignor) on Jun 18, 2004 at 18:26 UTC | |
by davido (Cardinal) on Jun 19, 2004 at 04:09 UTC | |
|
Re: Using HTML::TableExtract
by jZed (Prior) on Jun 18, 2004 at 16:06 UTC |