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)
-
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.
|