-   Programming (
-   -   Resolving URL script (

irfanhab 12-08-2005 05:48 AM

Resolving URL script
I have a list of URL's, I want to know which ones are valid, can someone write me a simple script in python or perl, which could tell me which sites are working (properly resolving) and which are not?

keefaz 12-08-2005 07:38 AM

Try (perl) :


use Socket;

# file where URLs are stored
my $file = '/path/to/url_file';

open URLS, "< $file" or die "Could not open $file: $!\n";

while (<URLS>) {
    next if /^$/;  # no need to test a blank line
    my $url = $_;
    s/http:\/\///;  # remove http:// from domaine name
    s/\/.*//;      # remove last / and URL path  if any

    if(gethostbyname $_) {
        print "$url is working\n";
    } else {
        print "$url is not working\n";

close URLS;

All times are GMT -5. The time now is 05:46 PM.