我試圖從給定的URL下載一些xml文件。下面是我所使用的各項─wget在Perl程序內不能正常工作
use strict;
use warnings;
my $url ='https://givenurl.com/';
my $username ='scott';
my $password='tiger';
system("wget --user=$username --password=$password $url") == 0 or die "system execution failed ($?): $!";
local $/ = undef;
open(FILE, "<index.html") or die "not able to open $!";
my $index = <FILE>;
my @childs = map /<a\s+href\=\"(AAA.*\.xml)\">/g , $index;
for my $xml (@childs)
{
system("wget --user=$username --password=$password $url/$xml");
}
但是當我運行此,它被卡在for循環wget命令的代碼。看來wget無法正確獲取文件?任何線索或建議?
謝謝。
人
另請參閱:http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – 2011-03-14 11:58:46
您是否嘗試用'print'替換'system' '?它是否卡在第一個「系統」上? 「系統」返回什麼? – Tim 2011-03-14 13:29:34
獲取多個文件後它會卡住..有時它會在最後一個文件中獲取兩個文件.. – Man 2011-03-14 13:38:23