Fetching question (this was once answered by Luke from Hong Kong)

J

Jeff M.

I'm trying to fetch a link and i dont need the content of the link i
just need the link itself. Here is what i mean:
Lets say when you go to: http://www.go.to/username it forwards you to:
http://www.geocities.com/username

So how do i fetch url http://www.go.to/username to find out which url
it forwarded me to.

Few years ago i was working with a programmer, Luke, from Hong Kong
and he was able to figure this out for me. And now i need this again,
Luke if you are out there please contact me.

Thanks
 
A

A. Sinan Unur

(e-mail address removed) (Jeff M.) wrote in @posting.google.com:
I'm trying to fetch a link and i dont need the content of the link i
just need the link itself. Here is what i mean:
Lets say when you go to: http://www.go.to/username it forwards you to:
http://www.geocities.com/username

So how do i fetch url http://www.go.to/username to find out which url
it forwarded me to.

Few years ago i was working with a programmer, Luke, from Hong Kong
and he was able to figure this out for me. And now i need this again,
Luke if you are out there please contact me.

Use the force, Luke, use the force.

Sorry, I could not resist.

Anyway, check out the documentation for the LWP module. The example given
in perldoc LWP is good enough to get you started. That is, read the
documentation first instead of trying to locate some guy called look. The
equivalent of the 'using the force' in programming is reading the docs.

use strict;
use warnings;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->agent("RedirectFinder ");

my $req = HTTP::Request->new(HEAD => 'http://some.url.invalid');
my $res = $ua->request($req);

if(my $rp = $res->previous) {
print $rp->header('Location');
}

__END__

Sinan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top