Thursday, July 30, 2009

Check a web page exists

Here is a short method to check if a web page exists from a perl script,
this script will test the existense of a page and do something as a result:

==========

#!/usr/bin/perl
use LWP::Simple;
print “Content-Type: text/htmlnn”;

$url = “ http://site.com/“;

if (head($url)) {
# ok document exists
print “OK: found $url”;
} else {
# something is not well
print “PROBLEM: $url is missing”;
}

=============

No comments:

Post a Comment