Skip to content

Instantly share code, notes, and snippets.

@asiansteev
Created November 13, 2009 02:10
Show Gist options
  • Save asiansteev/233522 to your computer and use it in GitHub Desktop.
Save asiansteev/233522 to your computer and use it in GitHub Desktop.
##
# feed it a url and it'll pass that url to a url shortener, pass the shortened url to another shortener
# and so on. in the end you should have a url that takes a couple of minutes to load. fun!
# in firefox, you'll need to up the network.http.redirection-limit in about:config to 1000 or so.
#
require 'net/http'
require 'rubygems'
require 'hpricot'
url = ARGV.shift
loop do
# get from ur.ly
doc = Hpricot::XML(
Net::HTTP.get_response(
URI.parse("http://ur.ly/new.xml?href=#{url}")
).body
)
puts url = "http://ur.ly/#{(doc/:urly).first['code']}"
### tr.im will temporarily ban your IP for this.
# get from tr.im
# doc = Hpricot::XML(
# Net::HTTP.get_response(
# URI.parse("http://tr.im/api/trim_url.xml?url=#{url}")
# ).body
# )
# puts url = (((doc/:trim).first)/:url).first.inner_html if (doc/:trim).first
# POST to rubyurl
doc = Hpricot.parse(
Net::HTTP.post_form(
URI.parse('http://rubyurl.com/api/links'),
{'website_url' => url}
).body
)
puts url = (doc/:permalink).inner_html
# GET from cli.gs
puts url = Net::HTTP.get_response(
URI.parse("http://cli.gs/api/v1/cligs/create?url=#{url}")
).body
# GET from is.gd
puts url = Net::HTTP.get_response(
URI.parse("http://is.gd/api.php?longurl=#{url}")
).body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment