Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i check links in a web page

Status
Not open for further replies.

bijuperl

Programmer
Apr 11, 2002
6
0
0
IN
I have a web page(index.html) which contains links to all the pages in the website.
I want to write a perl script which will check whether the links are correct.
If there is any working script, it would be very helpful.
I'm using the IDE "ActivePerl" for Windows.
 
Wrap this in a loop and you're done.

Code:
#!/usr/local/bin/perl
use LWP::Simple;
$url = '[URL unfurl="true"]http://www.nationalreview.com/';[/URL]
$started = time;

# this will get the HTML text
$content = get($url);
print "$content";
[code]
 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
I tried puttin this in a loop and had no luck. I would also like to check if web links on a web page are valid. I just want to check the links not any mail to stuff or any other complicated stuff.

Here is my forloop attempt:
[tt]
foreach $url (@url) {
$TheCheck = get($url);
if($url ne "") { print "OK: $url\n" }
else { print "Fail: $TheURL\n" }
}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top