gpt4 book ai didi

github-api - 如何通过 github api 获取热门 github 存储库列表?

转载 作者:行者123 更新时间:2023-12-02 22:42:19 25 4
gpt4 key购买 nike

我想要获取像这样的 github 趋势存储库列表 - https://github.com/trending?l=java但我在 https://developer.github.com/v3/ 没有找到任何类似的请求方法,如何通过趋势存储库获取 json 响应?

最佳答案

GitHub 似乎使用他们的 API 来编写趋势页面,并且不会将其作为特定 API 呈现出来。您需要使用 Repository Search API 。我已经关注了examples on this page ,它可以通过以下方式解决您的需求:

# We'll use the `date` command to get the date for "7 days ago"
$ date -v-7d '+%Y-%m-%d'
# => 2013-07-15

curl -G https://api.github.com/search/repositories --data-urlencode "sort=stars" --data-urlencode "order=desc" --data-urlencode "q=language:java" --data-urlencode "q=created:>`date -v-7d '+%Y-%m-%d'`"

然后从那里开始。您还可以通过在 OS X 上安装 jq 让您的生活变得更加轻松。或其他平台以获得更漂亮的输出:

curl -G https://api.github.com/search/repositories --data-urlencode "sort=stars" --data-urlencode "order=desc" --data-urlencode "q=language:java"  --data-urlencode "q=created:>`date -v-7d '+%Y-%m-%d'`" | jq ".items[0,1,2] | {name, description, language, watchers_count, html_url}"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- -- 77 161k 77 125k 0 0 131k 0 0:00:01 --:--:-- 0100 161k 100 161k 0 0 163k 0 --:--:-- --:--:-- --:--:-- 163k
{
"name": "vibrant.js",
"description": "Extract prominent colors from an image. JS port of Android's Palette.",
"language": "JavaScript",
"watchers_count": 1466,
"html_url": "https://github.com/jariz/vibrant.js"
}
{
"name": "JSPatch",
"description": "JSPatch bridge Objective-C and JavaScript using the Objective-C runtime. You can call any Objective-C class and method in JavaScript by just including a small engine.",
"language": "Objective-C",
"watchers_count": 830,
"html_url": "https://github.com/bang590/JSPatch"
}
{
"name": "KRVideoPlayer",
"description": "类似Weico的播放器,支持竖屏模式下全屏播放",
"language": "Objective-C",
"watchers_count": 524,
"html_url": "https://github.com/36Kr-Mobile/KRVideoPlayer"
}

关于github-api - 如何通过 github api 获取热门 github 存储库列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30525330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com