Skip to content

Instantly share code, notes, and snippets.

@vivien
Created February 10, 2011 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivien/819870 to your computer and use it in GitHub Desktop.
Save vivien/819870 to your computer and use it in GitHub Desktop.
A tiny Ruby API for the AlloURL service.
# A tiny Ruby API for the AlloURL service.
#
# Author: Vivien 'v0n' Didelot <vivien.didelot@gmail.com>
require 'open-uri'
module AlloURL
module_function
# Retrieves the link encapsulated in the AlloURL +url+.
def retrieve(url)
allo_url_base_url = 'http://209.212.147.251'
allo_url_timeout = 7
w = url.sub(/^.+\?w=/, '')
allo_url_frame_url = URI.escape("#{allo_url_base_url}/w.php?w=#{w}")
response = open(allo_url_frame_url).read
k = response.scan(/var k="(.+)"/).first.first
allo_url_frame_url = URI.escape("#{allo_url_base_url}/secur.php?k=#{k}")
sleep allo_url_timeout
response = open(allo_url_frame_url).read
link = response.scan(/href="(.+)" /).first.first
link
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment