我正在尝试从 github tensorflow 存储库中提取问题,该问题有超过 250 条评论。然而,我总是收到 30 个结果(根据 GitHub 分页),而我应该只收到 2 个结果。 这是我的代码:
owner = "tensorflow"
repo = "tensorflow"
n_comments = 250
url = f"https://api.github.com/repos/{owner}/{repo}/issues"
token = "mytokenhere"
params = {
'sort':'comments-desc',
'q': 'comments:>{n_comments}',
}
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3+json" # specifying json-formatted data
}
response = requests.get(url, headers = headers, params = params)
issues_with_sufficient_comments = []
if response.status_code == 200:
# Extract the JSON data
data = response.json()
for item in data:
issues_with_sufficient_comments.append(item['number'])
print(item['number'])
print(item['comments'])
else:
# Print error message if request failed
print(f"Error: {response.status_code}")
我也尝试过 url = f"https://api.github.com/repos/{owner}/{repo}/issues?q=comments:>250",这也没有帮助
133
。https://api.github.com/repos/tensorflow/tensorflow/issues?sort=comments&direction=desc&per_page=100
1. get all issues
2. filter by number of comments you wants (comments > n)
3. process
或
1. Use sort and direction parameter.
2.
-if all response issue are > n_required_comments.
- get new page
- repeat 2
- else
- filter any issue with < n_required_comments from last api call.
- return