Skip to content

Instantly share code, notes, and snippets.

@Ikuyadeu
Last active April 10, 2019 03:02
Show Gist options
  • Save Ikuyadeu/3287a6532c6073fd47d92401d8c3ed32 to your computer and use it in GitHub Desktop.
Save Ikuyadeu/3287a6532c6073fd47d92401d8c3ed32 to your computer and use it in GitHub Desktop.
[GitHub]
id = YourGitHubId
password = YourGitHubPass
"""
Get popular project
Before run
$ pip3 install PyGithub
$ touch config.json
Edit config.sjon
"""
import requests
import json
import csv
from github import Github
import configparser
config = configparser.ConfigParser()
config.read('config')
user = config["GITHUB"]["id"]
password = config["GITHUB"]["password"]
g = Github(user, password)
languages = ["Python", "Java", "JavaScript", "C++"]
for language in languages:
repos = g.search_repositories("stars:>0", sort="stars", language=language)
results = []
for x in repos[:10]:
results.append({"repo": x.name, "owner": x.owner.login,
"url": x.url, "forks": x.forks, "stars": x.stargazers_count})
with open("data/languages/" + language + ".csv", "w") as org_file:
writer = csv.DictWriter(
org_file, ["repo", "owner", "url", "forks", "stars"])
writer.writeheader()
writer.writerows(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment