Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Downloads JSON from the SE API for use with Mathias' script
require 'open-uri'
require 'net/http'
require 'zlib'
users = [13, 58, 116, 181, 218, 219, 292, 638, 796, 1916, 1922, 2220, 2269, 3117,
3791, 3936, 4160, 4408, 4977, 5472, 6730, 7001, 7833, 8318, 9058, 9388, 9495,
10355, 10639, 11118, 11610, 11791, 12285, 13247, 13414, 14447, 14692, 15589,
16529, 17580, 17666, 18202, 18387, 20234, 20448, 20459, 20519, 20749]
count = 1
users.each do |user|
print "\rprocessing %2i of %2i" % [count, users.length]
['questions', 'answers'].each do |kind|
posts = "http://api.stackexchange.com/2.0/users/#{user}/#{kind}" +
"?fromdate=1331856000&todate=1333411200" +
"&site=apple&pagesize=35&order=desc&sort=votes" +
"&key=oRRUIfSKB0gCiJ0jiYpPJQ(("
File.open("data/#{user}-#{kind}.json", "w") << Zlib::GzipReader.new(open(posts)).read
end
count += 1; sleep 0.2
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment