Created
June 23, 2014 01:44
-
-
Save thesowah/ee9999e789fbb86403f4 to your computer and use it in GitHub Desktop.
Utility script for Afridevcmty
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
# This utility class is help gather data while avoiding | |
# Github's seach restriction of 1,000 results | |
# and traverse through the results using Link headers | |
# FYI: Our results is about 2700 | |
require 'rest_client' | |
require 'json' | |
class Utility | |
@url = "https://api.github.com/search/users" | |
@dates = ["<=2012-01-01", "2012-01-01..2012-12-31", "2013-01-01..2013-12-31", ">=2014-01-01"] | |
def self.get_all | |
data = [] | |
@dates.each do |date| | |
begin | |
1.upto(Float::INFINITY) do |i| | |
params = {:params => {:q => "location:africa created:#{date}", :per_page => '100', :page => "#{i}"}} | |
response = RestClient.get @url, params | |
response = JSON.parse(response, :symbolize_names => true) | |
data.concat(response[:items]) | |
sleep 5 | |
end | |
rescue Exception => err | |
next | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment