This works for me (Win XP, Perl Activestate 5.8.8).
#!/usr/local/bin/perl
use strict;
use warnings;
use Data::Dumper;
use HTML::TableExtract;
use WWW::Mechanize;
$Data::Dumper::Indent = 1;
my $url = "http://www.sailwx.info/shiptrack/cruiseships.phtml";
my $m = WWW::Mechanize->new();
$m->get($url);
die unless $m->success;
my $input = $m->content;
my $te = HTML::TableExtract->new(
headers => [qw(Ship position)]
) or die qq{$!};
$te->parse($input);
foreach my $row ($te->rows) {
print Dumper($row);
}
outputs (extract)
$VAR1 = [
'Carnival Freedom',
"N 18\x{b0}30', W 077\x{b0}06'"
];
$VAR1 = [
'Carnival Glory',
"N 19\x{b0}24', W 064\x{b0}48'"
];
$VAR1 = [
'Azamara Journey',
"S 35\x{b0}06', W 056\x{b0}48'"
];
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.