in reply to (Ovid) Re: Checking external links for inappropriate content
in thread Checking external links for inappropriate content

NICE! I like the idea of returning every link that results in a redirect. Thanks, Ovid!

So I should set up an HTTP::Request, pass it to an LWP::UserAgent, and check the $response->{_rc} response code? Or is there an easier way?
  • Comment on Re: (Ovid) Re: Checking external links for inappropriate content

Replies are listed 'Best First'.
Re: Re: (Ovid) Re: Checking external links for inappropriate content
by vagnerr (Prior) on Feb 15, 2002 at 15:44 UTC
    Something like this may help...
    if ($res->is_success) { #Normal retrievel of content stuff }else{ #check for redirects if ($res->code() =~ /30[12]/){ #redirect codes (temp/perm) #grab the location my $remote_cgi = $res->header('Location'); { # Some servers erroneously return a relative URL for redirects, # so make it absolute if it not already is. local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1; my $base = $res->base; $remote_cgi = $HTTP::URI_CLASS->new($remote_cgi,$base)->abs($ba +se); } }else{ # Request failed normaly, broken link }
    Where $res is your result object

    ---If it doesn't fit use a bigger hammer