Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Well... I am not familiar with either of these packages and it is odd, because the example of the table extract comes from the perldoc... but it doesn't return an object. By dumping the variables it did return I got it to work, however. Here is my code.
use WWW::Mechanize; use HTML::TableExtract; $url="http://www.dhl-usa.com/TransitTimes/USTTimeStart.asp?nav=Transit +Times"; $service = "Service"; $arrival = "Arrival Date and Time"; $transit = "Days in Transit*"; my $mech = WWW::Mechanize->new(); $mech->get($url); $frmSvcCalc = "frmSvcCalc"; $mech->form_name($frmSvcCalc); $mech->set_fields( txtOrgZip => "53213", txtDestZip => "60056", ); $mech->field( "hdnAction", "Calculate" ); $mech->submit($frmSvcCalc); my $results2 = $mech->content; $te = HTML::TableExtract->new( headers => ['Service','Arrival Date and + Time','Days in Transit*'] ); $te->parse($results2); foreach $ts ($te->tables) { foreach $row (@$ts) { print join(',', @$row), "\n"; } }
This, for me, prints each row you want on a line with each td separated by a comma, which should get you far enough along :)

Update I was using version 1.08 and looking at docs on search.cpan.org for 2.06, take with a grain of salt :)

                - Ant
                - Some of my best work - (1 2 3)


In reply to Re: Problems with TableExtract by suaveant
in thread Problems with TableExtract by bcdeery

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 learning in the Monastery: (6)
As of 2024-04-20 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found