Created
February 10, 2011 03:20
-
-
Save vivien/819870 to your computer and use it in GitHub Desktop.
A tiny Ruby API for the AlloURL service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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