Problem using TableExtract 1.08

D

Darren Dunham

I'm trying to pull some data out of a table that I retrieve from an HTML
page. I found HTML::TableExtract and it looks like it could do what I
want. Is there a better module I should be using or any known problems
with it?

However, I'm having trouble getting the "header" method to behave
exactly like I want. The first thing I did was to have it print all the
tables from the html to see the bits. This is the relevant bit of the
code that does that...

# Examine all matching tables
foreach my $ts ($te->table_states) {
print "Table (", join(',', $ts->coords), "):\n";
print "MAP (", join(',', $ts->column_map), "):\n";
foreach my $row ($ts->rows) {
print join('<>', @$row), "\n";
}

And then this is the stuff from the top of the table I want...

Table (1,8):
MAP (0,1,2,3,4,5,6,7,8):
[Blah blah blah useless data on top line]<><><><><><><>
Player<>AB<>H<>HR<>RBI<>R<>OPS<>SB<>BA
Abad, Andy 1B BOS<>0<>0<>0<>0<>0<>0.000<>0<>0.0000
[.. table continues]

So I tried the simple "header" extraction method. If I supply all the
headers from the line that begins "Player", then I get no data. If I
supply some of the headers, I sometimes get data. The strange thing is
that simply rearranging the order will change whether or not data is
returned.

my $te = new HTML::TableExtract(
headers => [ "Player","AB","H","HR"],
);

# perl extract
# (no data returned).

Change the above to this...

my $te = new HTML::TableExtract(
headers => [ "Player","AB","HR","H"],
);

# perl extract
Table (1,8):
MAP (0,1,3,2):
Abad, Andy 1B BOS<>0<>0<>0
[... more data...]
#

So the order of the headers matters (which I don't think it should).

Is there any way to use the "headers" to simply select a table (rather
than relying on it being in position (1, 8) for example), but then
returning all columns, or is there something I'm doing wrong here?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top