free perl script - web site checker

0 replies
I wrote this to check my own sites, but theoretically you could put other people's sites in there too to see what's going on with them. I posted this for some guy in another forum, but figured it might be useful here since people might actually check this spot for scripts.

Keep in mind, a version of perl 5 is needed. ActivePerl has a good version for windows. If you use mac or linux you already have it most likely.

Basically a goes out there and checks the sites you put in the list in the script. If you give the script arguments it takes them and checks the remotes pages for that expression. It's worth noting if you know regex, you can use those patterns too (like [a-z]+ for finding any lowercase word).

Let me know if you have any questions of if you find it useful. I know I could add to it, but this is the free version for the internet marketing world

Code:
#!/usr/bin/perl
#kkoechel@gmail.com
use strict;
use warnings;
use LWP;
my $search = "@ARGV";#if you want to check the remote site for a pattern after
		     #getting a response, can use regular expressions
my @sites = qw(
		goodne.ws
		kkoechel.net
		mydigitalfutures.com
		lolhelp.us
		example.dead
		);
		#etc 
for my $site(@sites){
	my $ua = LWP::UserAgent->new;
	my $response = $ua->get("http://".$site);
	if($response->is_success){
		print "$site alive\n";
		if($search){
			my $html = $response->decoded_content;
			print "\talso: $search was NOT FOUND at $site\n" unless($html =~ m/$search/);
		}
	}else{
		print "$site no response\n";	
	}
}
__END__
usage example:
user@user-laptop:~/misc/helpingOthers$ perl checkSites.pl cash
goodne.ws alive
kkoechel.net alive
mydigitalfutures.com alive
lolhelp.us alive
example.dead no response
user@user-laptop:~/misc/helpingOthers$ perl checkSites.pl CASH IN
goodne.ws alive
	also: CASH IN was NOT FOUND at goodne.ws
kkoechel.net alive
	also: CASH IN was NOT FOUND at kkoechel.net
mydigitalfutures.com alive
lolhelp.us alive
example.dead no response
user@user-laptop:~/misc/helpingOthers$
#checker #free #perl #script #site #web

Trending Topics