-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitestocheck.pl
56 lines (43 loc) · 1.02 KB
/
sitestocheck.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use Mail::Message;
my $site = 'http://www.gimblerus.com/cgi-bin/x?task=home';
sub check {
my $site = shift or die 'no site supplied' ;
my $ua = LWP::UserAgent->new;
my $req = POST 'http://validator.w3.org/checklink/', [
uri => $site,
summary => 'on',
hide_type => 'all',
recursive => 'on',
depth => '-1',
check => 'Check'
];
warn $req->as_string;
$ua->request($req);
}
sub mail {
my ($site, $content) = @_;
my $message = Mail::Message->build (
From => 'checklink@metaperl.com',
To => 'metaperl@gmail.com',
'Content-Type' => 'text/html',
Subject => "Checklink Results: $site",
'X-Mailer' => 'Automatic mailing system',
data => [ $content ]
);
$message->send;
}
warn 1;
my $response = check $site;
warn 2;
if ($response) {
mail $site, $response->content;
} else {
die "could not browse $site";
}
warn 3;