Py-Github根据条件筛选repo的例子
Posted max_xbw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Py-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
以上是关于Py-Github根据条件筛选repo的例子的主要内容,如果未能解决你的问题,请参考以下文章