【Py-Github】根据条件筛选Github repo的例子
条件:
language:python commits:>100 contributors:>2 stars:>5 fork:0
实现:
from github import Github access_token = 'your_token' gh = Github(access_token) def search_repositories(q): try: repos=gh.search_repositories(query=q) except Exception, e: return None return repos if __name__ == '__main__': q = "language:Python forks:0 stars:>5" repos=search_repositories(q) min_num_of_commits=100 min_num_of_contributors = 2 final_repos=[] for repo in repos: num_of_commits=len(list(repo.get_commits())) num_of_contributors=len(list(repo.get_contributors())) if num_of_commits>min_num_of_commits and num_of_contributors>min_num_of_contributors: final_repos.append(repo) print 'name : ', repo.name print 'html_url : ', repo.html_url print 'url : ', repo.url print '#commits : ', num_of_commits print '#contributors : ', num_of_contributors
If you have any questions about this article, welcome to leave a message on the message board.
Brad(Bowen) Xu
E-Mail : maxxbw1992@gmail.com