【日記 21.03.19】GitHub API で1,000件以上検索したい奴
「nomi-sec/PoC-in-GitHub」は GitHub API で検索してリポジトリ情報を収集しているが、1,000以上は収集できない。
1ページに30件表示されるので34ページまでしか検索できず、35ページ以降はエラーとなる。
$ curl "https://api.github.com/search/repositories?q=\"CVE-2020-\"&page=35&sort=updated"
{
"message": "Only the first 1000 search results are available",
"documentation_url": "https://docs.github.com/v3/search/"
}
なので34ページ以内に収めるために、検索条件にリポジトリ作成日時を指定できる「created:」キーワードを使っている。
具体的には以下のような検索条件にして2分割している。
/search/repositories?q=\"CVE-2020-\"+created%3A>%3D2020-07-01&page=1&sort=updated"
/search/repositories?q=\"CVE-2020-\"+created%3A<%3D2020-06-30&page=1&sort=updated"
これで1,000件以上検索できるようになった。( ᐛ👐) パァ