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
Related Entries
- Learning Ruby in 3 Weeks
- Ruby on Rails is Agile Web Development
- Learning Ruby - Day 5
- Learning Ruby - Day 1
- Learning Ruby - Day 14
