我在试着屏蔽一些github的回复。我有一个组织名单,我想要筛选。对一些人来说,它工作得很好,而对另一些人来说,即使它们确实存在,我也会得到404没有找到错误:
github_api = Github(github_access_token)
print(github_api.get_organization('eosforce').get_repos()) File "C:/Users/haase/Documents/VL/cryptodevel/create_repos.py", line 100, in <module>
print(github_api.get_organization('eosforce').get_repos())
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\MainClass.py", line 296, in get_organization
headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}")
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\Requester.py", line 353, in requestJsonAndCheck
return self.__check(
File "C:\Users\haase\Documents\VL\pythonProject\lib\site-packages\github\Requester.py", line 378, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/orgs#get-an-organization"}例如,这可以很好地工作:
print(github_api.get_organization('bitcoin').get_repos())有人知道问题在哪里吗?
发布于 2021-05-12 17:32:30
这里的问题似乎是,所有你想要得到回复的组织都不需要在Github上有一个organization account。
例如:
因此,您使用的端点:https://docs.github.com/en/rest/reference/orgs#get-an-organization只适用于组织,它将返回一个未找到的带有用户帐户的组织的http状态(如力场)。
实现的第一步应该是检查您想要获得存储库的帐户是用户还是组织帐户。
然后,要获得用户存储库,请使用:
https://docs.github.com/rest/reference/repos#list-repositories-for-a-user
要获得组织存储库,请使用:
https://docs.github.com/rest/reference/repos#list-organization-repositories
有关如何在需要时使用这些端点的更多详细信息,请参见关于存储库的Github文档。
https://stackoverflow.com/questions/67508305
复制相似问题