Created
August 24, 2013 08:55
-
-
Save kechol/6326985 to your computer and use it in GitHub Desktop.
a simple script to fetch url schemes from http://handleopenurl.com/scheme.
This file contains hidden or 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
| # 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