我正在尝试从网页下载文件。
首先,我使用linkextractor 获取链接,然后我想使用lwp 下载它们。我是perl 中的新手编程。
我做了以下代码...
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TableExtract;
use HTML::LinkExtractor;
use LWP::Simple qw(get);
use Archive::Zip;
my $html = get $ARGV[0];
my $te = HTML::TableExtract->new(
keep_html => 1,
headers => [qw( column1 column2 )],
);
$te->parse($html);
# I get only the first row
my ($row) = $te->rows;
my $LXM = new HTML::LinkExtractor(undef,undef,1);
$LXM->parse(\$$row[0]);
my ($t) = $LXM->links;
my $LXS = new HTML::LinkExtractor(undef,undef,1);
$LXS->parse(\$$row[1]);
my ($s) = $LXS->links;
#-------
for (my $i=0; $i < scalar(@$s); $i++) {
print "$$s[$i]{_TEXT} $$s[$i]{href} $$t[$i]{href} \n";
my $file = '/tmp/$$s[$i]{_TEXT}';
my $url = $$s[$i]{href};
my $content = getstore($url, $file);
die "Couldn't get it!" unless defined $content;
}
我收到以下错误
Undefined subroutine &main::getstore called at ./geturlfromtable.pl line 35.
提前致谢!