WWW-Checksite-Validator

WWW-Checksite-Validator

am 18.08.2005 21:44:18 von dszostek

Hi,

I am having trouble figuring out how to write a script for
WWW::Checksite::Validator. Has anyone written a script using this
module that they could post to give me a better idea of how to use it?

Thanks in advance,
Dave

Re: WWW-Checksite-Validator

am 19.08.2005 07:50:41 von Sisyphus

"Dave" wrote in message
news:1124394258.547703.223580@z14g2000cwz.googlegroups.com.. .
> Hi,
>
> I am having trouble figuring out how to write a script for
> WWW::Checksite::Validator. Has anyone written a script using this
> module that they could post to give me a better idea of how to use it?
>

I don't use this module and the documentation is not easy to decipher.
Perhaps the test scripts that come with the source tarball may help - though
they are a little obfuscated through the use of Test::More.

Start with:

use warnings;
use WWW::CheckSite::Validator;

my $sp = WWW::CheckSite::Validator->new(
uri => "http://www.kalinabears.com.au/w32perl/index.html",
);

my $index = $sp->get_page;

'$index' is a hash reference - and it seems to me that it contains all of
the information you might want (though there's no guarantee that assessment
of mine is correct). You can access the information by dereferencing the
hash (as I did in the script below my signature) - though the process can
probably be simplified by calling appropriate methods on $sp, if you like to
experiment with that. I think that experimentation is the key to being able
to use this module effectively - at least experimentation is the only way
I'd be able to work out how to effectively use it.

Hope there's something here that helps get you started. If you have
(specific) questions about specific aspects of this module then feel free to
ask. I don't feel like attempting to come to terms with *every* aspect of it
:-)

Maybe all you really need is (as per 'perldoc WWW::CheckSite') :

use WWW::CheckSite;

my $wcs = WWW::CheckSite->new(
uri => 'http://www.test-smoke.org/',
prefix => 'tsorg',
save => 1,
);

$wcs->validate;

$wcs->write_report;
__END__

Also check 'perldoc WWW::CheckSite::Validator' if you haven't already.

Cheers,
Rob

use warnings;
use WWW::CheckSite::Validator;

my $sp = WWW::CheckSite::Validator->new(
uri => "http://www.kalinabears.com.au/w32perl/index.html",
);

my $index = $sp->get_page;

my %deref = %$index;
for(keys(%deref)) {print "$_: $deref{$_}\n"}
print "##############\n";

for(@{$deref{'links'}}) {
my %d = %$_;
for my $k(keys(%d)) {print "$k: $d{$k}\n"}
}
print "##############\n##############\n";

my $links = $sp->check_links();

my %deref2 = %$links;
for(keys(%deref2)) {print "$_: $deref2{$_}\n"}
print "##############\n";

for(@{$deref2{'links'}}) {
my %d = %$_;
for my $k(keys(%d)) {print "$k: $d{$k}\n"}
}
print "##############\n##############\n";

# 2 more ways of getting that last piece of info.
print $sp->check_links()->{'links'}->[-1]->{'uri'}, "\n";
print $index->{'links'}->[-1]->{'uri'}, "\n";