ngbabu has asked for the wisdom of the Perl Monks concerning the following question:

Dear All,

I am testing the weblinks for connectivity using Test::HTTPStatus module. I could able to test 187 and in those 165 links are success and 22 links are failed. When I test manually by entering the weblink in the browser out of 22, 5 weblinks are working fine.

I am not sure why this module is showing those 5 links as failure. Can somebody help in get it resolved.

My code is as follows:
unlink("linktest.log"); $xfile = "$ARGV[0]"; open(OUT, ">>linktest.log"); use XML::XPath; use XML::XPath::XMLParser; use Test::HTTPStatus tests=>1; $xp = XML::XPath->new(filename => $xfile); $nodeset1 = $xp->find('//xref/@href'); foreach $node1 ($nodeset1->get_nodelist) { $aid=XML::XPath::XMLParser::as_string($node1); $aid=~s!href="!!g; $aid=~s!"!!g; $aid=~s! !!g; $a=http_ok( $aid, HTTP_OK ); sleep 10; print OUT "$aid\n" if ($a == 0); } close(OUT);

Regards,
Ganesh

Replies are listed 'Best First'.
Re: Test::HTTPStatus problem
by tilly (Archbishop) on Feb 20, 2009 at 05:31 UTC
    Sometimes links have transient problems. Try them again after it works manually and the problem may have gone away.

    If not then my best guess is that sometimes webservers do different things depending on the user agent. In particular they block anything that looks like a robot, which you would.

Re: Test::HTTPStatus problem
by zwon (Abbot) on Feb 20, 2009 at 10:49 UTC

    Check the status for working links in browser, maybe it's not HTTP_OK.