如何使用Perl下载文件?

问题描述:

我在Windows XP上运行Perl,我需要从URL下载文件 http://marinetraffic2.aegean.gr/ais/getkml.aspx

I'm running Perl on Windows XP, and I need to download a file from the URL http://marinetraffic2.aegean.gr/ais/getkml.aspx.

我该怎么做?我试图使用WWW :: Mechanize,但是我不能让我的头脑。

How should I do this? I have attempted using WWW::Mechanize, but I can't get my head around it.

这是我使用的代码:

my $url = 'marinetraffic2.aegean.gr/ais/getkml.aspx';
my $mech = WWW::Mechanize->new;
$mech->get($url);


我会使用LWP::Simple 为此。

#!/usr/bin/perl

use strict;
use warnings;

use LWP::Simple;

my $url = 'http://marinetraffic2.aegean.gr/ais/getkml.aspx';
my $file = 'data.kml';

getstore($url, $file);