首先有token才可以不被github限制访问频率,然后要得到指定的仓库对象,然后得到pull_request
对象,这个对象是一个查询结果集,子集是一个一个pull_request对象。在一个一个对象中包含了pull_request的所有数据
from github import Github
token = 'access_token'
g = Github(login_xxxx = token)
repo = g.get_repo('指定的仓库名')
#get_pulls()参数不写的,就是获取所有open的pull_request.
pull_requests = repo.get_pulls()
for pr in pull_requests:
#这里可以用debug模式,获取你想要的数据,例如分支,目标分支,content等数据
author = pr.xx.longin
content = pr.head.ref
.....

本文介绍了如何利用Python的`github`库访问GitHub API,通过访问令牌获取指定仓库的Pull Request。首先设置访问令牌,然后获取仓库对象,接着调用`get_pulls()`方法获取所有open状态的Pull Request。对于每个Pull Request对象,可以提取如作者、目标分支等信息。

被折叠的 条评论
为什么被折叠?



