要下载几十个网页到本地,一个类似目录的网页上有下一级页面的链接,只需将下一级页面的相对路径提取出来,和目录页的路径组合成一个绝对路径,然后获取内容并保存到电脑即可。
- #!/usr/bin/perl
- use warnings;
- use strict;
- use LWP::Simple;
- use LWP::UserAgent;
- my $url='http://****/DOCUMENTS/Inst_Notes/NR9.6/1350OMS-HPUX_9.6.1.0.9AD4/';
- #get html
- my $ua = LWP::UserAgent->new();
- my $rv = $ua->get($url);
- #print $rv->content;
- #parse the subpath
- my @sublink=($rv->content =~ m/href="(.*)"/g);
- #make the full path,get the html and save!
- my $eachlink;
- my $each_FullPath;
- foreach $eachlink(@sublink) {
- $each_FullPath="$url$eachlink";
- my $feedback=getstore($each_FullPath,"E:\\Tech\\TMN\\NR9.6\\instHtml\\$eachlink");
- }
阅读(2456) | 评论(0) | 转发(0) |