Skip to content

Instantly share code, notes, and snippets.

@arowser
Forked from ngsankha/github-scrape.py
Created January 19, 2013 00:20
Show Gist options
  • Save arowser/4569806 to your computer and use it in GitHub Desktop.
Save arowser/4569806 to your computer and use it in GitHub Desktop.
import csv, httplib, json
from string import ascii_lowercase
con = httplib.HTTPSConnection('api.github.com')
languages = ['java', 'c', 'ruby', 'python', 'javascript']
for lang in languages:
with open(lang + '.csv', 'wb') as csvfile:
csvwriter = csv.writer(csvfile, delimiter = ',', quotechar='"', quoting = csv.QUOTE_MINIMAL)
for ch in ascii_lowercase:
print("Processing repos with " + ch + " for language " + lang)
con.request('GET', '/legacy/repos/search/' + ch + '?language=' + lang)
data = json.load(con.getresponse())
for repo in data['repositories']:
csvwriter.writerow([repo['name'], repo['username'], repo['followers'], repo['forks'], repo['fork']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment