proxytoworld
V2EX  ›  问与答

如何循环下载 GitHub release 页面的文件

  •  
  •   proxytoworld · Aug 17, 2024 · 2115 views
    This topic created in 825 days ago, the information mentioned may be changed or developed.

    release 里面发布了几十个包,有脚本能循环下载 release 里面的文件吗,找了一下没找到。

    7 replies  •  2024-08-19 09:47:49 +08:00
    proxytoworld
    proxytoworld
    OP
    Aug 17, 2024
    1
    可以用 cli gh release download -p "*" -D gh_latest -R username/repo
    1rv013c6aiWPGt24
    1rv013c6aiWPGt24
    Aug 17, 2024 via Android
    2
    笨办法,把版本号+下载链接写个遍历,挨个下,没匹配到的跳过匹配到的下载
    zsh2517
    zsh2517
    Aug 17, 2024❤️1
    3
    如果问题在于一个链接一个链接找比较麻烦,而且量不是特别大(能接受一部分手动的话)

    可以选中链接们复制,去这里( https://euangoddard.github.io/clipboard2markdown/) 或者 https://codepen.io/zsh2517/pen/ZEdEdzw 这里,读取剪贴板为 markdown/富文本格式。

    然后配合正则表达式和简单的代码解析出来下载链接就行
    hguandl
    hguandl
    Aug 17, 2024
    4
    可以使用 GitHub API 。需要注意的是这个有 IP 访问频率限制,所以最好带上 token 请求。

    https://docs.github.com/rest/releases/assets#list-release-assets
    https://docs.github.com/rest/authentication/authenticating-to-the-rest-api
    xxx027
    xxx027
    Aug 17, 2024 via Android
    5
    有 api 的,稍作处理就可以全都下下来了
    0o0O0o0O0o
    0o0O0o0O0o
    Aug 17, 2024
    6
    我一般尽量避免用 API

    curl -fsL https://github.com/junegunn/fzf/releases/expanded_assets/v0.54.3 | \
    grep -oP '(?<=<a href=")/[^"]+/releases/download/[^"]+(?=")' | \
    xargs -I {} curl -fLO "https://github.com/{}"
    proxytoworld
    proxytoworld
    OP
    Aug 19, 2024
    7
    @zsh2517 你这个倒是合理,用富文本带出来
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1918 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:19 · PVG 12:19 · LAX 20:19 · JFK 23:19
    ♥ Do have faith in what you're doing.