如何抓取GitHub pull request的评论?

时间:2019-10-03 06:43:25

标签: python-3.x comments github-api pull-request review

如何提取开发人员在GitHub pull request的统一差异部分中提供的GitHub pull request注释?我想创建一个带有注释的csv文件进行分析。

URL检索GitHub上最常见的十大分叉存储库

url ='https://api.github.com/search/repositories?q=language:java&sort=forks&order=desc&per_page=10&page=1'

resp = urllib.request.urlopen(urllib.request.Request(url))。read()。decode('UTF-8')

在python对象中转换JSON响应

json_obj = json.loads(resp_text)

10个最分叉的存储库

用于json_obj ['items']中的回购:

# j is the current page number
for j in range(1, 11):
    url = 'https://api.github.com/repos/' + repo['owner']['login'] + '/' + repo['name'] + '/pulls/comments?direction=desc&per_page=10&page=' + str(j) + '&access_token=' + github_access_token

    json_obj = json.loads(urllib.request.urlopen(urllib.request.Request(url)).read().decode('UTF-8'))
    # save json to csv
    for data in json_obj:
        csvwriter.writerow(data['body'])

rdata.close()

我想从前10个存储库中检索请求请求评论注释正文(必填文本),并保存在CSV文件中。

0 个答案:

没有答案