Friday, May 11, 2012

Where Does That Shortened URL Go?

The growing prevalence of URL shortening services always left me wondering if there was a way to find out what a shortened URL really linked to without actually clicking the link in a browser.  Here is a short Perl script that I came up with to find out what the destination URL is for a URL that has been shortened.

 #!usr/bin/perl

# Copyright 2012- Christopher M. Frenz
# This script is free software it may be used, copied, redistributed, and/or modified
# under the terms laid forth in the Perl Artisic License

use LWP;

my $ua = LWP::UserAgent->new;

$link='http://t.co/5tOuMCRy';

$response=$ua->get($link);
$result=$response->request();
$url = $result->uri();

print $url;

No comments: