Solved

dead-link detection

Posted on 1998-11-30
4
289 Views
Last Modified: 2013-12-25
I need a perl script to detect a dead-link
something like this:
            deadLink( URL )
deadLink() returns true if link exists, false otherwise.

anyone?
0
Comment
Question by:shlomoy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
squimph earned 100 total points
ID: 1829827
You can use the modules in the libwww package (http://www.perl.com/CPAN-local/modules/by-module/LWP/) to test a URL:

For example, call the following from the command line with the URL you want to test as the parameter:

#!/usr/bin/perl
$URL = $ARGV[0];
use LWP::UserAgent;
$ag = new LWP::UserAgent;
$ag->agent("CustomLinkChecker/1.0" . $ag->agent);
$req = new HTTP::Request GET => $URL;
$results = $ag->request($req);
if ( $results->is_success ) {
    print "URL exists.\n"

} else {
    print "Bad URL\n";
}
0
 
LVL 8

Author Comment

by:shlomoy
ID: 1829828
from: http://www.perl.com/CPAN-local/modules/by-module/LWP/libwww-perl-5.41.readme
---begin quote---
If you want to install a private copy of libwww-perl in your home
directory, then you should try to produce the initial Makefile with
something like this command:

  perl Makefile.PL LIB=~/perl

The Makefile.PL program will start out by checking your perl
installation for a few packages that are recommended to be installed
together with libwww-perl.
----end quote----

where can I obtain this makefile?
0
 
LVL 1

Expert Comment

by:squimph
ID: 1829829
Well, installing libwww-perl is a separate question but here goes...

First consider talking to your system administrator to ask that they install libwww in the central perl directory so everyone on the system can use it (most web servers already have it installed... I assume you've already checked)

If the admin refuses to install it, the instructions you have above will do it... 'perl Makefile.PL LIB=~/perl' will create a file called 'Makefile' ... then type 'make' and 'make install' to install the package.
0
 
LVL 8

Author Comment

by:shlomoy
ID: 1829830
Thanks!!
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question