#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use WWW::Mechanize::TreeBuilder;
my $mech = WWW::Mechanize->new();
WWW::Mechanize::TreeBuilder->meta->apply($mech);
$mech->get('file:///home/example/path/index.html');
die "Cannot open file: ", $mech->response->status_line
unless $mech->success;
my @list = $mech->look_down(_tag => "a", class => "links);
foreach (@list) {
my $url = "file:///home/example/path/";
$url = $url . $_->attr("href");
print $_->as_text(), " - ", $url, "\n";
$mech->get($url);
$mech->back();
}
####
Web Scraper Testing Grounds
Test Page for WWW::Mechanize scraping
####
This is the S1 page, first in set
####
This is the S2 page, second in set
####
This is the S3 page, third and final
####
mdro79@mycpu$ ./mech.pl
S1 Link Content - file:///home/example/path/s1.html
Use of uninitialized value in concatenation (.) or string at ./scrMe.pl line 31.
Use of uninitialized value $tag in string eq at /usr/local/share/perl/5.14.2/HTML/Element.pm line 1109.
Use of uninitialized value $tag in string eq at /usr/local/share/perl/5.14.2/HTML/Element.pm line 1109.
- file:///home/example/path/
Use of uninitialized value in concatenation (.) or string at ./scrMe.pl line 31.
Use of uninitialized value $tag in string eq at /usr/local/share/perl/5.14.2/HTML/Element.pm line 1109.
Use of uninitialized value $tag in string eq at /usr/local/share/perl/5.14.2/HTML/Element.pm line 1109.
- file:///home/example/path/