你好,
我试图获取具有特定主题的存储库列表,然后使用返回的属性,但是在尝试获取未知数据时,PaginatedList 中返回的存储库对象会引发错误:
Traceback (most recent call last):
File "github-crawler.py", line 6, in <module>
print(i, repo.archive_url)
File "/home/user/.local/lib/python3.6/site-packages/github/Repository.py", line 2407, in get_topics
self.url + "/topics",
File "/home/user/.local/lib/python3.6/site-packages/github/Repository.py", line 745, in url
self._completeIfNotSet(self._url)
File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 259, in _completeIfNotSet
self._completeIfNeeded()
File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 263, in _completeIfNeeded
self.__complete()
File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 268, in __complete
self._url.value
File "/home/user/.local/lib/python3.6/site-packages/github/Requester.py", line 262, in requestJsonAndCheck
return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
File "/home/user/.local/lib/python3.6/site-packages/github/Requester.py", line 278, in __customConnection
if not url.startswith("/"):
AttributeError: 'NoneType' object has no attribute 'startswith'
下面是代码示例:
from github import Github
g = Github(per_page=300)
i = 1
for repo in g.search_topics('security'):
print(i, repo.archive_url)
i += 1
可以在这里测试: https :
环境:
Linux ubuntu 4.15.0-36-generic x86_64 GNU/Linux
蟒蛇 3.6.6
PyGithub 1.43.2
有什么帮助吗?
谢谢
稍后我会修复它:p
也许,错误的代码在这里。 @jacquerie
也许,错误的代码在这里。 @jacquerie
嗯? 我认为我没有为此贡献代码......
只是扫一眼代码。 search_topics 似乎返回了 GitHub 存储库的分页列表,但 API 似乎返回了一个主题列表,包括以下属性:
我认为这可能是根本问题。
是的,API 端点 /search/topics 返回与提供的关键字相关的主题列表,而不是用该主题标记的存储库列表(这有点令人困惑,也许?)。
在我的代码中,我使用了其他 API 端点,并且运行良好。
但是,PyGithub 中的方法应该是固定的。
欢迎公关
最有用的评论
欢迎公关