简体   繁体   English

使用Java GitHub API搜索存储库时如何获得超过100个结果?

[英]How to get more than 100 results when searching for repositories with the Java GitHub API?

I'm currently using the org.eclipse.egit.github.core-2.1.5 GitHub API for Java with the goal of searching for all repositories on GitHub using Python. 我目前正在使用org.eclipse.egit.github.core-2.1.5 GitHub API for Java,目标是使用Python在GitHub上搜索所有存储库。

I know how to do the search, but the RepositoryService.searchRepositories(query) method only returns 100 results. 我知道如何进行搜索,但RepositoryService.searchRepositories(query)方法只返回100个结果。 If I redo the search, the same results are given back. 如果我重做搜索,会返回相同的结果。 Is there any way to get the next 101-X search results? 有没有办法获得下一个101-X搜索结果?

Is there any way to use a command similar in functionality to curl https://api.github.com/legacy/repos/search/Go?language=Go within the Java GitHub API? 有没有办法在Java GitHub API中使用类似功能的命令来curl https://api.github.com/legacy/repos/search/Go?language=Go If so, what method would offer this functionality? 如果是这样,提供此功能的方法是什么?

Judging by the code , there are several overloaded variants of searchRepositories , one of which accepts a query parameter, a language parameter and a startPage parameter. 根据代码判断,有几个重载的searchRepositories变体,其中一个接受query参数, language参数和startPage参数。 This means you should be able to run the query that you specified by using: 这意味着您应该能够使用以下命令运行您指定的查询:

RepositoryService.searchRepositories("Go", "go")

If you then want to get more results, you would specify the page as well: 如果您想获得更多结果,还可以指定页面:

RepositoryService.searchRepositories("Go", "go", 2)
RepositoryService.searchRepositories("Go", "go", 3)
...

Unfortunately I cannot see a way for you to tell how many pages there actually are. 不幸的是,我找不到告诉你实际有多少页面的方法。 The code used by searchRepositories to do the request suggests that the first request should in fact return all the results across all the pages, but if you are only getting 100 results back, then it seems this is not the case. searchRepositories用于执行请求的代码表明第一个请求实际上应该返回所有页面中的所有结果,但如果您只获得100个结果,那么情况似乎并非如此。 You might just have to keep trying later pages until you get no results back. 你可能只需继续尝试以后的页面,直到你得不到任何结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM