使用Python和githubapi从rep收集数据

2024-04-26 05:12:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在研究一个项目,它涉及到python使用githubapi从repo(https://github.com/)收集stars、contributors、PR和issues的数量,并将其存储在CSV文件中。你知道吗

我试图使用BeautifulSoup4,但API方法是一种更稳定的方法。 下面是我的小片段。我不知道如何使用githubapi(pygithub)获取公司v/s非公司(检查外部贡献者)的某些贡献者提出的问题的数量信息。你知道吗

from github import Github
# using username and password
# or using an access token
g = Github("***************************")
for repo in g.get_user().get_repos():
    print(repo.name)

print("**********Get Current Repos**********")
user = g.get_user()
user.login
print(user.login)
repo = g.get_repo("<any-repo>/<any-repo>")
repo.name
print(repo.name)
print("********Get the Repo Topics**************")

repo = g.get_repo("<any-repo>/<any-repo>")
repo.get_topics()
print(repo.get_topics())

print("*****Get the Star Count*************")
repo = g.get_repo("<any-repo>/<any-repo>")
repo.stargazers_count
print(repo.stargazers_count)
print("********Get the Open Issues*********")
repo = g.get_repo("<any-repo>/<any-repo>")
open_issues = repo.get_issues(state='open')
for issue in open_issues:
    print(issue)

print("******Get the Branch Count*******")
repo = g.get_repo("<any-repo>/<any-repo>")
print(list(repo.get_branches()))

附言:我还是Python迷。你知道吗


Tags: the方法namegithubget数量公司repo