Skip to content

Instantly share code, notes, and snippets.

@kechol
Created August 24, 2013 08:55
Show Gist options
  • Select an option

  • Save kechol/6326985 to your computer and use it in GitHub Desktop.

Select an option

Save kechol/6326985 to your computer and use it in GitHub Desktop.
a simple script to fetch url schemes from http://handleopenurl.com/scheme.
# coding: utf-8
require "rubygems"
require "nokogiri"
require 'open-uri'
SITE_URL = "http://handleopenurl.com/scheme?page="
page = 0
last = false
result = {}
loop do
page += 1
doc = Nokogiri::HTML(open(SITE_URL + page.to_s))
if(doc && !last)
doc.css("#schemeIndex .scheme").each do |node|
appname = node.css("h1").first.text
schemes = []
if(!appname.empty? && node.css(".code").count > 0)
schemes = node.css(".code").first.text.split(" ")
# end if stop paging
if(result.has_key?(appname))
last = true
break
end
puts "#{appname}: #{schemes.to_s}"
result[appname] = schemes
end
end
else
break
end
# DO NOT ATTACK
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment