通过github.api获取问题数量

问题描述 投票:0回答:2

我的任务是使用github.api获取未解决的问题数量。不幸的是,当我解析任何存储库时,我得到相同的数字--30。

import requests


r = requests.get('https://api.github.com/repos/grpc/grpc/issues')
count = 0
for item in r.json():
    if item['state'] == 'open':
        count += 1

print(count)

有没有办法获得真正的问题?

python python-3.x github-api
2个回答
0
投票

请参阅有关Link响应头的文档,您也可以传递statefilters。

你必须翻页。

http://.../issues?page=1&state=open
http://.../issues?page=2&state=open

0
投票

/issues/端点是分页的:这意味着您将不得不遍历几个页面来解决所有问题。

但是有更好的方法来获得你想要的东西。 GET /repos/:owner/:repo直接给出了存储库中的未解决问题的数量。

例如,在https://api.github.com/repos/grpc/grpc上,您可以看到:

  "open_issues_count": 1052,

单击here以查看此端点的文档。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.