Hi All, Thank you for the suggestions! I have never been able to figure out Net::Perl I should have been more specific. I use LWP::UserAgent a lot and would like to master redirect URL's with it. Problem: it just times out on me. And not the 20 seconds I asked for either. More like several minutes. And "$res->redirects" returns what looks like an reference address pointer I am doing something wrong. cat Url.Redirest.Test.pl

#!/usr/bin/perl use strict; use warnings; #use diagnostics; #use diagnostics "-verbose"; use constant MaxTime1 => 20; # Seconds # use Net::Nslookup qw ( nslookup ); use LWP::UserAgent; # use LWP::Protocol qw ( https ); use Term::ANSIColor qw ( BOLD BLUE RED GREEN RESET ); my $Debug="yes"; sub GetUrlRedirect ( $$ ) { # Return $Url's redirected web page. Black string if none if locat +ed # Reference: http://stackoverflow.com/questions/26087546/perl-print +-the-redirected-url # system ('curl -s "SomeUrl" -w %{redirect_url}'); my $IAm = ( caller(0) )[3]; # Incoming: my $Url = $_[0]; my $Caller = "$_[1]" . "$IAm"; my $ua = LWP::UserAgent->new; $ua->timeout ( MaxTime1 ); $ua->show_progress; my $req = new HTTP::Request(GET => $Url); print STDERR "$Caller requesting $Url\n"; my $res = $ua->request($req); print STDERR "$Url redirects to $res->redirects\n"; if ( ! $res->is_success ) { print STDERR BOLD RED " ERROR ${Caller}: unable to obtain a redirect web page f +or ", $Url, RESET, "\n"; return ""; } else { if ( "$Debug" eq "yes" ) { print STDERR "RedirectUrl = <$res-> +redirects>\n"; } return $res->redirects; } } my $IAm = "UrlRedirectTest.pl "; my $WebSite = 'http://usa.kaspersky.com/files/?file=kis&program=on +e&lang=en&track=pu_kiskis_usen'; my $RedirectUrl = GetUrlRedirect ( $WebSite, $IAm ); print "WebSite $WebSite\nredirects to\n$RedirectUrl\n"; END

UrlRedirectTest.pl main::GetUrlRedirect requesting http://usa.kaspersky.com/files/?file=kis&program=one&lang=en&track=pu_kiskis_usen http://usa.kaspersky.com/files/?file=kis&program=one&lang=en&track=pu_kiskis_usen redirects to HTTP::Response=HASH(0x24e9808)->redirects RedirectUrl = <HTTP::Response=HASH(0x24e9808)->redirects> WebSite http://usa.kaspersky.com/files/?file=kis&program=one&lang=en&track=pu_kiskis_usen redirects to 1


In reply to Re: URL Redirect by Todd Chester
in thread URL Redirect by Todd Chester

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.