Skip to content

Instantly share code, notes, and snippets.

@jkbecker
Forked from jmduke/bigTech.py
Created June 6, 2018 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkbecker/65eb04ba1136914cd35e673300935eee to your computer and use it in GitHub Desktop.
Save jkbecker/65eb04ba1136914cd35e673300935eee to your computer and use it in GitHub Desktop.
Grab data from various organizations from Github.
import requests
import operator
companies = ["facebook", "aws", "google", "yahoo", "dropbox", "twitter", "paypal", "linkedin", "mozilla", "adobe"]
api_url = "https://api.github.com/orgs/{}/repos"
data = {}
for company in companies:
data[company] = {'forks': 0, 'stars': 0, 'repos': 0, 'languages': {}}
r = requests.get(api_url.format(company))
json = r.json()
while "next" in r.links:
r = requests.get(r.links['next']['url'])
json += r.json()
for repo in json:
try:
data[company]['repos'] += 1
data[company]['forks'] += repo['forks_count']
data[company]['stars'] += repo['watchers_count']
data[company]['languages'][repo['language']] = data[company]['languages'].get(repo['language'], 0) + repo['size']
except:
continue
print "COMPANY", "REPOS", "FORKS", "STARS"
for company in data:
print company, data[company]['repos'], data[company]['forks'], data[company]['stars'], max(data[company]['languages'].iteritems(), key=operator.itemgetter(1))[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment