Hello there, am pretty newish to perl,mainly have a java background, so do let me know if I'm missing something completely obvious.

I have been looking at various examples to try to get them to work, but so far haven't been able to get any using parse_file to work, only managed to get one working, but it was using parse() for parsing a html string.

For more background, I'm on windows 64 bit, and using strawberry perl, and I did install all the prerequisites for html::tableextract thru cpan. If possible, what I'd love is for an example of extracting table data from a html file already saved locally, and I should hopefully be able to fumble my way around from there.

Essentially, what I need to do is to extract some Table rows from a html file thats saved on my computer. And my apologies for the pretty horribly formatted post, and thanks for having a look!

edit: can't seem to post in the thread, probably doing something wrong.

aitap: This is part of the file I'll be parsing (it's pretty horribly formatted, and there are empty td tags sometimes.)

<tr> <td>2012/07/30</td> <td><a href="http://www.zone-h.org/archive/special=1/notifier=Dg4nx">Dg4nx</a +></td> <td>H</td> <td></td> <td><a href="http://www.zone-h.org/archive/domain=www.bauan.gov.ph">R</a></td +> <td><img src=" +../../images/cflags/png/us.png" alt="United States" title="United Sta +tes"></td> <td><img src="../../images/star.gif" borde +r="0"></td> <td>www.bauan.gov.ph </td> <td>Linux</td> <td><a href="http://www.zone-h.org/mirror/id/18160940">mirror</a></td> </tr>

As to examples, one I'm trying is http://search.cpan.org/~msisk/HTML-TableExtract-2.10/lib/HTML/TableExtract.pm but I seem to be missing something. I keep seeing a "can't call method "tree" on an undefined value at line 5" error when using this code from the TableExtracts examples(I have tried parsing in a html file $html_file = "page1.html"; , but it doesn't seem to be working)

use HTML::TableExtract qw(tree); $te = HTML::TableExtract->new( headers => [qw(Date Notifier H M R L D +omain OS View)] ); $te->parse_file($html_file); $table = $te->first_table_found; $table_tree = $table->tree; $table_html = $table_tree->as_HTML; $table_text = $table_tree->as_text; $document_tree = $te->tree; $document_html = $document_tree->as_HTML;

(My input likely won't fit this, but I'm just trying to get an example working to start with, I know I'm missing something, but not quite sure what.

influx: I'll give that a shot, thanks. appreciate the responses!


In reply to Queries on HTML::TableExtract - How to parse from saved html file by howdoesitwork

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.