本文介绍了如何使用Perl下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Windows XP上运行Perl,我需要从URL下载文件。
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);
推荐答案
我会使用为此。
#!/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);
这篇关于如何使用Perl下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!