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

I'm still getting an error with these modifications: "Can't call method "tree" on unblessed reference"
  • Comment on Re^6: HTML::TableExtract (parse table column from an HTML page)

Replies are listed 'Best First'.
Re^7: HTML::TableExtract (parse table column from an HTML page)
by erroneousBollock (Curate) on Oct 07, 2007 at 13:11 UTC
    The only reason you'd get that is if $table is not returned from $te->first_table_found.

    Try this to see whether HTML::TableExtract (which ISA HTML::Parser) has correctly parsed the HTML:

      $te->parse($content) || die "couldn't parse HTML\n";

    -David

      My code didn't died while parsing the content.

        OK let's take WWW::Mechanize out of the equation, for the moment. Does this stand-alone snippet work for you?

        use strict; use warnings; use HTML::TableExtract qw/ tree /; my $html = <<EOT; <html> <head> <title>test page</title> <head> <body> <table> <tr><td>parse me</td></tr> </table> </body> </html> EOT my $te = HTML::TableExtract->new; $te->parse($html); my $table = $te->first_table_found; my $tree = $table->tree; print $tree->cell(0,0)->as_text;

        BTW, your test HTML is malformed (there's no closing <head> tag), but that doesn't affect the output of the script, at least on my machine...

Re^7: HTML::TableExtract (parse table column from an HTML page)
by Not_a_Number (Prior) on Oct 07, 2007 at 13:02 UTC
    Well it works for me (whereas with your code I get the same error as you).