check if urls work

Do you have a list of urls (one per line) and you do not want to check them by hand? Then try this code. It will open g1.txt (the file with your urls), then it checks every line. The urls that do work will be stored in g2.txt. The sites that do not work will get stored in g3.txt. Be aware: sites that forward the user are stored in g3.txt, too.

 

 

open (ERSTE, "g1.txt") || die "fiel g1 not found\n";

@urls = <ERSTE>;
close (ERSTE);


use LWP::Simple;

foreach (@urls)
{
if (head($_))
{
# these urls do work
open (OUTFILE, ">>g2.txt");
print OUTFILE "$_";
close (OUTFILE);
}
else
{
# these urls do not work
open (OUTFILE, ">>g3.txt");
print OUTFILE "$_";
close (OUTFILE);


}
}


 

Back to previous page

 Get Free Autoresponder

Enter your email address below and you will receive a powerful Autoresponder and our Special Ezine for free:

(Please use your real email address or else you won't receive the free script)

Name: *
Email: *

Or you can subscribe by clicking this link to send an email automatically:

mailto:amlmEzine@DrQuek.com