Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Those are some pretty nasty tables (50 or so of them). All sorts of empty rows and cells embedded throughout. In cases like these, it's better to extract all tables and filter based on inspecting particular cells. For example:
#!/usr/bin/perl use strict; use warnings; use LWP::Simple; use HTML::TableExtract; my $data = get('http://www.flalottery.com/exptkt/c3.htm'); my $te = HTML::TableExtract->new; $te->parse($data); for my $t ($te->tables) { my $rc = -1; my($d, $c) = $t->coords; for my $r ($t->rows) { ++$rc; @$r = map { s/^[^a-z0-9]//i; $_ } grep { /[a-z0-9]/i } grep { defined $_ } @$r; next unless @$r && $r->[0] =~ m/^\d+\/\d+\/\d+$/; print "row $d:$c:$rc: ", join(':', @$r), "\n"; } }
The grep/grep/map part eliminates empty cells and gets rid of the   entities that precede the M/E indicators. The 'next' statement afterwards eliminates empty rows and non-dated rows. This is a shotgun approach. You could easily filter each row using specific column indexes, for example.

In reply to Re: Lotto table extraction by mojotoad
in thread Lotto table extraction by LordSoahc

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found