I've gotten alot of help with removing white space, etc. in my extracted tables by searching here, but I'm having one problem I haven't seen a solution posted for yet. I'm extracting a table where one of the headers I want to keep is embedded in another table. ie. the headers look like this when extracted: header 1,,header 3, header 4 ...etc. That's because header 2 is in another table. Actually in that part of the table there are two additional tables (the first formatting the name I want, the second a search bar). I have no idea how to pull this data out (other than just going to a 'C' like for loop and pulling out $row2,$row4 from the full table maybe?). Is there a way to specify a header location instead of name? Any one help? Here's my code:
#!/usr/bin/perl use strict; use HTML::TableExtract; use LWP::UserAgent; my $url = 'http://some.foo.com'; my $ua = LWP::UserAgent->new; my $te = new HTML::TableExtract( headers=> ['Header 2','Header 4'], +depth => 0, count => 3); my $res = $ua->request(HTTP::Request->new(GET => $url), sub {$te->parse($_[0])}); use Data::Dumper; $Data::Dumper::Useqq = 1; foreach my $ts ($te->table_states) { print "Table (", join(',', $ts->coords), "):\n"; foreach my $row ($ts->rows) { foreach (@$row) { tr{\t\r\n\xAO}{ }s; s{^\s+}{}; s{\s+$}{}; } # print Dumper $row; print join(',', @$row), "\n"; } }

In reply to Embedded Table Headers with HTML::TableExtract by hoopsbwc34

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.