在Github中,是否有一种方法可以让我看到回购的下载数量?


当前回答

11年后…… 下面是一个小的python3代码片段,用于检索最近100个发行版资产的下载计数:

import requests

owner = "twbs"
repo = "bootstrap"
h = {"Accept": "application/vnd.github.v3+json"}
u = f"https://api.github.com/repos/{owner}/{repo}/releases?per_page=100"
r = requests.get(u, headers=h).json()
r.reverse() # older tags first
for rel in r:
  if rel['assets']:
    tag = rel['tag_name']
    dls = rel['assets'][0]['download_count']
    pub = rel['published_at']
    print(f"Pub: {pub} | Tag: {tag} | Dls: {dls} ")

Pub: 2013-07-18T00:03:17Z | Tag: v1.2.0 | Dls: 1193 
Pub: 2013-08-19T21:20:59Z | Tag: v3.0.0 | Dls: 387786 
Pub: 2013-10-30T17:07:16Z | Tag: v3.0.1 | Dls: 102278 
Pub: 2013-11-06T21:58:55Z | Tag: v3.0.2 | Dls: 381136 
...
Pub: 2020-12-07T16:24:37Z | Tag: v5.0.0-beta1 | Dls: 93943 

Demo

其他回答

如前所述,GitHub API返回二进制文件发布的下载计数。我开发了一个小脚本,通过命令行轻松获得下载计数。

基于VonC和Michele Milidoni的答案,我创建了这个bookmarklet,它显示了github托管发布的二进制文件的下载统计数据。

注意:由于浏览器与内容安全策略实现相关的问题,bookmarklet可能会暂时违反一些CSP指令,并且在启用CSP时在github上运行时基本可能无法正常工作。

虽然这是非常不鼓励的,你可以禁用CSP在Firefox作为 临时的解决方案。打开about:config并设置security.csp.enable 为假。

有一个很好的Chrome扩展,完全做你想要的: GitHub发布下载

如前所述,您可以通过API获得有关您的版本的信息。

对于那些使用WordPress的人,我开发了这个插件:GitHub Release Downloads。它可以让你获得下载计数,链接和更多的信息发布GitHub存储库。

为了解决最初的问题,短代码[grd_count user=" user " repo="MyRepo"]将返回存储库的下载数量。这个数字对应于一个GitHub存储库的所有版本的所有下载计数值的总和。

例子:

为了更清楚地说明这一点: 对于这个github项目:stant/ mdcsvimportter2015 https://github.com/stant/mdcsvimporter2015 在 https://github.com/stant/mdcsvimporter2015/releases

转到HTTP或https:(注意添加了“api.”和“/repos”) https://api.github.com/repos/stant/mdcsvimporter2015/releases

你会得到这个json输出,你可以搜索"download_count":

    "download_count": 2,
    "created_at": "2015-02-24T18:20:06Z",
    "updated_at": "2015-02-24T18:20:07Z",
    "browser_download_url": "https://github.com/stant/mdcsvimporter2015/releases/download/v18/mdcsvimporter-beta-18.zip"

或者在命令行执行: Wget——no-check-certificate https://api.github.com/repos/stant/mdcsvimporter2015/releases