Problem using TableExtract 1.08

Discussion in 'Perl Misc' started by Darren Dunham, Sep 8, 2003.

  1. 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.

    --
    Darren Dunham
    Unix System Administrator Taos - The SysAdmin Company
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
     
    Darren Dunham, Sep 8, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sdfgsd
    Replies:
    6
    Views:
    212
    sdfgsd
    Oct 9, 2003
  2. Michael Bourgon
    Replies:
    0
    Views:
    99
    Michael Bourgon
    Sep 30, 2004
  3. Paul

    Perl HTML::TableExtract Question

    Paul, Apr 17, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    222
  4. Jim Monty
    Replies:
    0
    Views:
    119
    Jim Monty
    May 16, 2005
  5. Maqo
    Replies:
    3
    Views:
    165
    Bob Walton
    May 25, 2005
Loading...

Share This Page