我正在尝试通过命令行通过脚本搜索github字符串。在浏览器中这很容易,因为我可以在github.com上输入搜索查询:
“电子邮件”或“联系人”和“ test.com”
我正在寻找“电子邮件”或“联系人”字符串和“ test.com”
哪个导致浏览器查询: https://github.com/search?q=%22email%22+OR+%22contact%22+AND+%22test.com%22&type=Code
我正在尝试通过脚本模拟上面的浏览器查询,以在终端中查看结果,所有结果URL都为“ type = Code”。
我写了一个python脚本,它不起作用。
#!/usr/bin/python
from github import Github
g = Github('API_KEY')
repositories = set()
# Note: Gets rate limited and fails if too many hits
content_files = g.search_code(query='user:test.com contact email')
for content in content_files:
repositories.add(content.repository.full_name)
rate_limit = g.get_rate_limit()
if rate_limit.search.remaining == 0:
print('WARNING: Rate limit on searching was reached. Results are incomplete.')
break
for repo in sorted(repositories):
print(repo)
rate_limit = g.get_rate_limit()
print('Search rate limit:')
print(rate_limit.search)
感谢您的协助。