Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
LWP can successfully follow the redirect of webpages, but how can I get the URI of the page that LWP is reading after the redirect? Reason: I need to scrape that page and reconstruct the relative paths of the links contained in that page.
I can obtain something with:
my $ua = LWP::UserAgent->new; my $ret = $ua->get($site); my $url = $ret->request->uri .""; print "URL returned: ".$url."\n";
However, this script is NOT able to give me the target URI if the redirection is caused by a line of code in the HTML (vs. with a redirection from the server side), such as <meta http-equiv="refresh" content="0; url=site/index.html" />
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get URI of redirected page with LWP
by choroba (Cardinal) on Feb 20, 2022 at 17:58 UTC | |
|
Re: get URI of redirected page with LWP
by kschwab (Vicar) on Feb 21, 2022 at 14:03 UTC | |
|
Re: get URI of redirected page with LWP
by Anonymous Monk on Feb 21, 2022 at 10:08 UTC |