Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Can I detect a broken link in my CGI Perl script

by Zach (Initiate)
on Jul 27, 2001 at 21:22 UTC ( [id://100383]=perlquestion: print w/replies, xml ) Need Help??

Zach has asked for the wisdom of the Perl Monks concerning the following question:

How can I automatically determine if a link to a website in my script is broken (page doesn't exist) when the user clicks the link? If the link is broken, I want to link to a default page that explains that the link was broken. Thanks

Originally posted as a Categorized Question.

  • Comment on Can I detect a broken link in my CGI Perl script

Replies are listed 'Best First'.
Re: Can I detect a broken link in my CGI Perl script
by agent00013 (Pilgrim) on Aug 08, 2001 at 20:35 UTC
    I'm not sure about the CGI part of it, but for the actual checking of the link you might want to look into LWP::UserAgent and for an example of LWP::UserAgent in action, try looking here. It's a long script, but maybe it'll give you some ideas.

    You may just want to let the server handle 404 errors on your side. If it's their server with the bad link, just validate your links every so often with a cron job and have somebody look over the results every so often to take out links that are permanently down. Checking every link as you click it would waste system resources and slow down your site more than necessary.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://100383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-18 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found