Created
November 18, 2015 14:59
-
-
Save matkoniecz/8b930d6779c57c1a70e8 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
require 'net/http' | |
require 'json' | |
require 'pp' | |
url = URI.parse('http://taginfo.openstreetmap.org/api/4/key/values?key=shop&sortname=count&sortorder=desc') | |
req = Net::HTTP::Get.new(url.to_s) | |
res = Net::HTTP.start(url.host, url.port) {|http| | |
http.request(req) | |
} | |
data = JSON.parse(res.body)["data"] | |
all = 0 | |
bad = 0 | |
data.each {|e| | |
all += e["count"] | |
if e["value"].include?(";") | |
bad += e["count"] | |
end | |
} | |
puts all | |
puts bad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment