|laziness, impatience, and hubris|
Fast fetching of HTML response codeby mrguy123 (Hermit)
|on May 30, 2012 at 08:28 UTC||Need Help??|
mrguy123 has asked for the
wisdom of the Perl Monks concerning the following question:
I am writing a tool that checks if links are working or not. The idea is to fetch the link, check the error code, and if the error code is valid do a few more tests on the HTML response page
I was wondering, is there a way to quickly fetch only the response code without the rest of the HTML data? This means that if the code is bad (e.g. 401) I can move on to the next link, but if it is OK I can fetch the rest of the data for further testing.
For example, if I run the code below
It takes me about 1.5 seconds to get the response code (403). If I can somehow get it faster, it will make a big difference when I am testing 1000s of links
So, do you think this is even possible or just wishful thinking on my behalf?
Thanks, Mister Guy
Note: I am using LWP::UserAgent for the testing but can also use other modules if necessary
UPDATE: Used HEAD instead of GET for the HTTP request but the response time didn't improve
UPDATE 2: Used HEAD as compared to GET in 50 different links, and in some of them the HEAD request was indeed faster. Therefore the way to go is to use HEAD and of course parallel your processes if you want faster link checking. Thanks for the help
Hardware: The parts of a computer system that can be kicked.