I'm trying to pull the Ground Transit days off of the table at this URL:
http://www.dhl-usa.com/TransitTimes/USTTimeRslts.asp?nav=TransitTimes&
+oz=53213&oc=1&oh=ORD&dz=60056&dc=1&dt=1/9/2006&tt=1&hy=&zn=2&am=Y
but I either get nothing (with the code I have here) or I get the error "can't call method "rows" on an undefined value at TableExtract.pm line 224.
$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;
print OUTFILE $results2;
$te = HTML::TableExtract->new( headers => [qw($service $arrival $trans
+it)] );
$te->parse($html_string);
foreach $ts ($te->tables) {
print "Table (", join(',', $ts->coords), "):\n";
foreach $row ($ts->rows) {
print join(',', @$row), "\n";
}
}
The other code that I try that gives me the error is:
my $te = HTML::TableExtract->new( headers => [qw($service $arrival $tr
+ansit)] );
$te->parse($html_string);
foreach my $row ($te->rows) {
foreach my $cell (@$row) {
print $cell;
}
}
I've tried a few other ways, but I obviously don't & can't get it. I'm beggin for help, and so is my hair (or what's left of it).
-
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.