Skip to content

Instantly share code, notes, and snippets.

@matkoniecz
Created November 18, 2015 14:59
Show Gist options
  • Save matkoniecz/8b930d6779c57c1a70e8 to your computer and use it in GitHub Desktop.
Save matkoniecz/8b930d6779c57c1a70e8 to your computer and use it in GitHub Desktop.
#!/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