in reply to Re: extract URLs from text
in thread extract URLs from text

I suspect you intended to reply to Unshortening t.co links.

"Should work for any shortened URL"

The first search result I could find for 'url shorten', which didn't require payment or signing up was https://shorturldotat, which does not work with this code, however the following does work:

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use feature 'say'; use Data::Dumper; my $url = 'https://shorturl[dot]at/REDACTED'; my $uaname = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 ( + KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36'; my $ua = LWP::UserAgent->new; $ua->agent( $uaname ); my $resp = $ua->get($url); my $final = $resp->request()->uri(); while ($resp) { say $resp->request()->uri(); $resp = $resp->previous(); } say "Final URL: $final";

In short I don't think you're going to find a one size fits all solution, without automating a browser like WWW::Mechanize::Chrome.

Update: url cloaked a little, it's a bit spammy.