I want to get last of redirect URL.
like
url_1 : http://on.fb.me/4VGeu url_2 : https://www.facebook.com/
I want to get url_2 by url_1 in perl. Previous source is below.
sub get_redirect_location
{
my ($url) = @_;
my $ua = LWP::UserAgent->new;
$ua->proxy('http', 'SAMPLE_PROXY');
my $req = new HTTP::Request(GET => $url);
my $res = $ua->request($req);
return $res->headers_as_string;
}
Thanks in advance.
You can find the request that lead to a response using
$response->request()
You can get the previous response in the chain using
$response->previous()
All together:
while ($response) {
say $response->request()->uri();
$response = $response->previous();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With