lea*_*ord 3 github github-api python-3.x
我使用以下代码来获取存储库的星星,但它只返回 Bootstrap 存储库的 40000 颗星,这低于实际的 70717 颗星。但是它返回 JQuery 存储库的正确星星(31445)。为什么Bootstrap检索星星不正确?
#!/usr/bin/python
from github import Github
# XXX: Specify your own access token here
ACCESS_TOKEN = ''
client = Github(ACCESS_TOKEN, per_page=100)
# Specify a username and repository of interest for that user.
REPO_LIST=[('twbs','bootstrap'),('jquery','jquery')]
for USER,REPO in REPO_LIST:
user = client.get_user(USER)
repo = user.get_repo(REPO)
# Get a list of people who have bookmarked the repo.
# Since you'll get a lazy iterator back, you have to traverse
# it if you want to get the total number of stargazers.
stargazers = [ s for s in repo.get_stargazers() ]
print("Number of stargazers", len(stargazers))
Run Code Online (Sandbox Code Playgroud)
小智 6
响应正文将指示给定资源列表的分页是否受到限制:
\n\n\xe2\x9d\xaf curl https://api.github.com/repos/twbs/bootstrap/stargazers\\?per_page\\=100\\&page\\=401\n{\n "message": "In order to keep the API fast for everyone, pagination is limited for this resource. Check the rel=last link relation in the Link response header to see how far back you can traverse.",\n "documentation_url": "https://developer.github.com/v3/#pagination"\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1007 次 |
| 最近记录: |