[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] checking URLs




} 
} Is there a simple way to check if an external URL is valid (i.e. if the
} document exist/is accessible or even to evaluate its size before deciding
} what to do with it) ???

Yes, you do a HEAD request.  This asks the server to send only the http
headers for a document.  If the server is up, it will tell you whether
or not a document exists, and if it does, it will almost always tell
you the MIME type and the size.

I've got a script I use to do individual HEAD requests that uses my Mac
port of Roy Fielding's libwww-perl-0.40 and some of my own library
stuff.  All of that can be found on
<http://mors.gsfc.nasa.gov/MacPerl.html>  I'll stick head.pl on mors
and you can take a look; you will at the very least need to change a
path in the file.  It will be at
<ftp://mors.gsfc.nasa.gov/pub/MacPerl/Scripts/head.pl.  head.pl is a
quick, ugly hack of a Unix script that comes with libwww-perl-0.40.  If
you have a group of URL's to do, you might want to take a look at
testlinks.pl instead.

} 
} Thanks in advance, Luca Postpischl
} 
} 
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us