我正在尝试使用 perl 从站点下载文件。我选择不使用 wget 以便我可以学习如何这样做。我不确定我的页面是否没有连接,或者我的语法是否有问题。还有什么是检查您是否正在连接到页面的最佳方法。
#!/usr/bin/perl -w
use strict;
use LWP;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->credentials( '********' , '********'); # if you do need to supply server and realms use credentials like in [LWP doc][2]
$mech->get('http://datawww2.wxc.com/kml/echo/MESH_Max_180min/');
$mech->success();
if (!$mech->success()) {
print "cannot connect to page\n";
exit;
}
$mech->follow_link( n => 8);
$mech->save_content('C:/Users/********/Desktop/');