我是一名 Python 新手,我正在尝试提取 Github 上“python”类别中最受好评的项目。不幸的是,它没有给我所有的结果,因此给了我不正确的信息。
我的代码中的内容是这样的:
import requests
# Make an API call and store the response.
url = "https://api.github.com/search/repositories?q=language:python&sort=stars"
headers = {"Accept": 'application/vnd.github.v3+json'}
r = requests.get(url, headers=headers)
print(f"Status code: {r.status_code}")
# Store API response in a variable.
response_dict = r.json()
print(f"Total repositories: {response_dict['total_count']}")
# Explore information about the repositories.
repo_dicts = response_dict['items']
print(f"Repositories returned: {len(repo_dicts)}")
# Examine all of the repos.
print("\nSelected information about each repository: ")
for repo_dict in repo_dicts:
print(f"Name: {repo_dict['name']}")
print(f"Owner: {repo_dict['owner']['login']}")
print(f"Stars: {repo_dict['stargazers_count']}")
print(f"Repository: {repo_dict['html_url']}")
print(f"Created: {repo_dict['created_at']}")
print(f"Updated: {repo_dict['updated_at']}")
print(f"Description: {repo_dict['description']}")
现在,在 Github 上搜索时,我知道最受关注的项目是 vinta/awesome-python。但每当我运行此代码时,第一个值是:
Name: Auto-GPT
Owner: Significant-Gravitas
Stars: 145932
Repository: https://github.com/Significant-Gravitas/Auto-GPT
Created: 2023-03-16T09:21:07Z
Updated: 2023-08-08T00:39:08Z
Description: An experimental open-source attempt to make GPT-4 fully autonomous.
Name: Python-100-Days
Owner: jackfrued
Stars: 138354
Repository: https://github.com/jackfrued/Python-100-Days
Created: 2018-03-01T16:05:52Z
Updated: 2023-08-08T01:09:10Z
Description: Python - 100天从新手到大师
在 API Github 页面上,我找到了它不起作用的原因:
incomplete_results = true
。
但我不知道如何解决这个问题。有人可以向我解释一下吗?
我也遇到了同样的问题。这个问题你解决了吗?