Hi there, I am trying to extract a table from a html file based on the table class. I dont seem to be getting any output at all. Can someone help me??? WOuld really appreciate it!
#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use DBI; use IO::Socket; use lib '.'; use ATweb qw(%form $db $dbh %config ); use strict; local %form = &ATweb::fetch_form; my $db = &ATweb::mysql_connect; my $maintable; my $html_file = $config{'static_dir'}."/admin/documents/ghs_addresse.t +xt"; use HTML::TableExtract; use Data::Dumper; my $doc_html; local $/=undef; open FILE, "$html_file" or die "Couldn't open file: $html_file $!"; binmode FILE; $doc_html = <FILE>; close FILE; my $te = HTML::TableExtract->new( attribs => { class => 'generalinfo' }, ); $te->parse_file("$doc_html"); print "Content-Type: text/html\n\n"; for my $table ( $te->tables ) { print Dump $table->columns; }
Heres the relevant contents of the html file:
<table cellspacing="0" cellpadding="0" class="generalin +fo"> <tr ><th class="rtl"></th><th colspan="2">Vermietu +ng</th><th class="rtr"></th></tr> <!-- header --> <tr><td class="left">&nbsp;</td><td>&nbsp;</td><td +></td><td class="right">&nbsp;</td></tr> <!-- spacer --> <tr> <td class="left">&nbsp;</td> <td class="text"><strong>Name</strong></td> <td class="text">Kaspar Flütsch</td> <td class="right">&nbsp;</td> </tr> <tr> <td class="left">&nbsp;</td> <td class="text"><strong>Adresse</strong></td> <td class="text">Schreinerei<br>7246 St. Antönien</td> <td class="right">&nbsp;</td> </tr> <tr> <td class="left">&nbsp;</td> <td class="text"><strong>Tel. Gesch&auml;ft</strong></td> <td class="text">081 332 23 31</td> <td class="right">&nbsp;</td> </tr> <tr> <td class="left">&nbsp;</td> <td class="text"><strong>Tel. Privat</strong></td> <td class="text">081 332 23 31</td> <td class="right">&nbsp;</td> </tr> <tr><td class="rbl"></td><td class="rb">&nbsp;</td>< +td class="rb">&nbsp;</td><td class="rbr"></td></tr> <!-- footer --> </table>

In reply to HTML::TableExtract problem by bkerr

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.