获取旧问题的数量和存储库最活跃成员的 table(登录名和提交数)

Getting the number of old issues and the table (login and number of commits) of the most active members of the repository

我无法使用 github.api 获取上述信息。阅读文档并没有多大帮助。对带日期的工作仍然没有完全的了解。这是我获取未解决问题的代码示例:

import requests
import json
from datetime import datetime


username = '\'
password = '\'

another_page = True
opened = 0
closed = 0
api_oldest = 'https://api.github.com/repos/grpc/grpc/issues? 
per_page=5&q=sort=created:>`date -v-14d "+%Y-%m-%d"`&order=asc'
api_issue = 'https://api.github.com/repos/grpc/grpc/issues? 
page=1&per_page=5000'
api_pulls = 'https://api.github.com/repos/grpc/grpc/pulls?page=1'

datetime.now()
while another_page:
    r = requests.get(api_issue, auth=(username, password))
    #json_response = json.loads(r.text)
    #results.append(json_response)
    if 'next' in r.links:
        api_issue = r.links['next']['url']
        if item['state'] == 'open':
             opened += 1
        else:
             closed += 1 
    else:
        another_page=False
datetime.now()

print(opened)

您的代码存在一些问题。比如item代表什么?。可以按如下方式修改您的代码以迭代并获取未解决问题的数量。

import requests

username = '/'
password = '/'

another_page = True
opened = 0
closed = 0

api_issue = "https://api.github.com/repos/grpc/grpc/issues?page=1&per_page=5000"


while another_page:
    r = requests.get(api_issue, auth=(username, password))
    json_response = r.json()
    #results.append(json_response)
    for item in json_response:
        if item['state'] == 'open':
             opened += 1
        else:
             closed += 1 

    if 'next' in r.links:
        api_issue = r.links['next']['url']
    else:
        another_page=False

print(opened)

如果您想要在过去 14 天内创建的问题,您可以使用以下 URL.

提出 api 请求
api_oldest = "https://api.github.com/repos/grpc/grpc/issues?q=sort=created:>`date -d '14 days ago'`&order=asc"