Last active
April 10, 2019 03:02
-
-
Save Ikuyadeu/3287a6532c6073fd47d92401d8c3ed32 to your computer and use it in GitHub Desktop.
This file contains 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
[GitHub] | |
id = YourGitHubId | |
password = YourGitHubPass |
This file contains 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
""" | |
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