Validating Links

Andrew Spiers (Andrew.Spiers@ics.uci.edu)
Wed, 24 Dec 1997 07:47:24 -0000


I have got some code (example below) that extracts links from a page. =
How do I check that these links are valid web pages before I go and get =
them ? The reason for this question is that it is also finding gifs and =
links within the page itself ?

Many Thanks

Andrew Spiers



Code Follows,

#!/usr/local/bin/perl -wT

use LWP::Simple;=20
use LWP::UserAgent;
use HTML::Parse;=20
use HTML::Element;
use HTML::FormatText;

$|=3D1;

$html =3D get "some page";

$parsed_html =3D HTML::Parse::parse_html($html);

for (@{ $parsed_html->extract_links() }){

 $link =3D $_->[0];

 print "Getting page : $link\n";

 Now go get page