在Github中,是否有一种方法可以让我看到回购的下载数量?
当前回答
这里是一个使用pip install PyGithub包的python解决方案
from github import Github
g = Github("youroauth key") #create token from settings page
for repo in g.get_user().get_repos():
if repo.name == "yourreponame":
releases = repo.get_releases()
for i in releases:
if i.tag_name == "yourtagname":
for j in i.get_assets():
print("{} date: {} download count: {}".format(j.name, j.updated_at, j._download_count.value))
其他回答
这里是一个使用pip install PyGithub包的python解决方案
from github import Github
g = Github("youroauth key") #create token from settings page
for repo in g.get_user().get_repos():
if repo.name == "yourreponame":
releases = repo.get_releases()
for i in releases:
if i.tag_name == "yourtagname":
for j in i.get_assets():
print("{} date: {} download count: {}".format(j.name, j.updated_at, j._download_count.value))
有一个很好的Chrome扩展,完全做你想要的: GitHub发布下载
2019年的答案:
对于克隆的数量,您可以使用https://developer.github.com/v3/repos/traffic/#clones(但请注意,它只返回过去14天的计数) 为了获得你的资产(附加到发行版的文件)的下载数量,你可以使用https://developer.github.com/v3/repos/releases/#get-a-single-release(确切地说,是资产列表项的“download_count”属性作为响应)
Github API不再提供所需的信息。看看Stan Towianski的回答中提到的发布页面。正如我们在回答的评论中讨论的那样,Github API只报告他每次发布的三个文件中的一个的下载量。
我已经检查了解决方案,在这个问题的其他一些答案。Vonc的回答体现了Michele Milidoni解决方案的关键部分。我安装了他的gdc脚本,结果如下
# ./gdc stant
mdcsvimporter.mxt: 37 downloads
mdcsvimporter.mxt: 80 downloads
How-to-use-mdcsvimporter-beta-16.zip: 12 downloads
正如您可以清楚地看到的,gdc没有报告tar.gz和zip文件的下载计数。
如果您想在不安装任何东西的情况下进行检查,请尝试Somsubhra在他的回答中提到的安装解决方案的网页。填写“stant”作为Github用户名和“mdcsvimportter2015”作为存储库名称,你会看到如下内容:
Download Info:
mdcsvimporter.mxt(0.20MB) - Downloaded 37 times.
Last updated on 2015-03-26
唉,还是只有一个没有下载tar.gz和zip文件的报告。我仔细检查了Github的API返回的信息,但它没有提供任何地方。目前,API返回的download_count还远远不够完整。
很晚了,但这是你想要的答案:
https://api.github.com/repos/ [git username] / [git project] /releases
接下来,在数据中找到您要查找的项目的id。它应该在顶部附近,在url旁边。然后,导航到
https://api.github.com/repos/ [git username] / [git project] /releases/ [id] / assets
名为download_count的字段就是答案。
编辑:在你的用户名和项目名中大写字母很重要
推荐文章
- 了解Git和GitHub的基础知识
- 在GitHub上有一个公共回购的私人分支?
- 只用GitHub动作在特定分支上运行作业
- Git合并与强制覆盖
- 是否有一个链接到GitHub下载文件的最新版本的存储库?
- GitHub -致命:无法读取用户名https://github.com':没有这样的文件或目录
- Github:我能看到回购的下载数量吗?
- 如何运行一个github-actions步骤,即使前一步失败,同时仍然失败的工作
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何取消在github上的拉请求?
- HEAD和master的区别
- 在另一个目录中运行操作
- GitHub克隆与OAuth访问令牌
- 我可以在GitHub上对要点进行拉请求吗?