这是我希望的最后一个问题。我正在使用 $mech->follow_link 尝试下载文件。出于某种原因,虽然保存的文件只是我第一次打开的页面,而不是我想要关注的链接。这是我应该从链接下载文件的正确方法吗?我不想使用 wget。
#!/usr/bin/perl -w
use strict;
use LWP;
use WWW::Mechanize;
my $now_string = localtime;
my $mech = WWW::Mechanize->new();
my $filename = join(' ', split(/\W++/, $now_string, -1));
$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/') or die "Error: failed to load the web page";
$mech->follow_link( url_regex => qr/MESH/i ) or die "Error: failed to download content";
$mech->save_content("$filename.kmz");