in reply to Re: Re: Re: help with link checking
in thread help with link checking
Anyway... I've pasted my final code below and it works. I was just wondering if there was a more efficient way to do it. Right now I am making two requests for the url. I figure this eats up bandwidth and just plain takes longer. Can someone offer a little input? Thanks!
#!/usr/bin/perl use LWP::UserAgent; ($ua = LWP::UserAgent->new)->timeout(20); $url = "http://fly.hiwaay.net/~dbwalker/josie.mp3"; if(($ua->request(HTTP::Request->new('HEAD', $url)))->code() == 200) { $redirect = $ua->simple_request(HTTP::Request->new('HEAD', $url)); if ($redirect->code == 301 or $redirect->code == 302) { print "BAD\n"; } else { print "GOOD\n"; } } else { print "BAD\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: help with link checking
by merlyn (Sage) on Mar 07, 2001 at 04:22 UTC |