How to Decode TinyURLs with Ruby

18 Aug 2007 in Programming, Ruby on Rails by Garrick


def reverse_tinyurl(tinyurl)
  require ‘open-uri’
  require ‘net/http’


  url = Net::HTTP.get_response(URI.parse(tinyurl)).to_hash['location'].to_s
end

This should also work for any url that is a known redirect whether it be a tinyurl.com, urltea.com, rubyurl.com, or what have you.


Comment | Trackback URL Short Link:

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Related Entries




Creative Commons License
About Sitemap XHTML Sitemap XML
Wordpress theme is a heavily hacked version of "Modicus Remix" by Art Culture. Original by Upstart Blogger