in reply to Re^2: HTML::TableExtract (parse table column from an HTML page)
in thread HTML::TableExtract (parse table column from an HTML page)

That's straight from the documentation, so it probably can't find a table in the HTML source you've given it.

-David

  • Comment on Re^3: HTML::TableExtract (parse table column from an HTML page)

Replies are listed 'Best First'.
Re^4: HTML::TableExtract (parse table column from an HTML page)
by cafaro (Novice) on Oct 07, 2007 at 11:37 UTC
    I made a local HTML test page to be parsed with my Perl script, this is my Perl code:
    #!/usr/bin/perl use WWW::Mechanize; use HTML::TableExtract; sub parse { $mech = WWW::Mechanize->new(autocheck => 1); $mech->get("file:///home/cafaro/omertascript/test.html"); $content = $mech->content(); $te = HTML::TableExtract->new(depth => 0); $te->parse($content); $table = $te->first_table_found; $tree = $table->tree; print $tree->cell(0,0); } parse();
    ... and this is my HTML code:
    <html> <head> <title>test page</title> <head> <body> <table> <tr><td>parse me</td></tr> </table> </body> </html>
      And did you print $content to see that it contains what you think ? (local and remote versions)

      -David

        print "$content\n"; gives me:
        <html> <head> <title>test page</title> <head> <body> <table> <tr><td>parse me</td></tr> </table> </body> </html>

      Change your second line to:

      use HTML::TableExtract qw( tree );

      You also need to change your print line to:

      print $tree->cell(0,0)->as_text;
        I'm still getting an error with these modifications: "Can't call method "tree" on unblessed reference"