I'm trying to send a http request to an url and check the content of the url using following script. However, by just check whether the content is empty or not can't tell whether a site is working.
#use all required modules here;
my $url = "a url here";
my $timeout = 30;
my ($page_content, $res);
eval{
alarm($timeout);
$res = $ua->get($url);
alarm(0);
}
$page_content = $res->content if $res->is_success;
However, the above can't detect a website problem, for example, I got
Fatal error: Call to a member function FetchRow() on a non-object in /home/world/public_html/index.php on line 290
from the $page_content
.
So I add this to check the website:
$page_content = 0 if $page_content !~ m{<html\b.*?>.*?<body\b.*?>.*?</body>.*</html>}si;
My question is: is there a function to check whether a website is working except using the above regular expression checks?