V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
millet230413
V2EX  ›  GitHub

关于 github 文件下载的问题

  •  
  •   millet230413 · 80 天前 · 2213 次点击
    这是一个创建于 80 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我通过 wget 或者 curl 到 github 上面下载一个源文件,我用浏览器点击直接下载,下载到的是正常的源文件,但是使用 wget / curl 下载到的就是一个 json 文件,这个 json 文件里面描述了我要下载的文件。即使使用 copy permalink 获取到的下载链接,用 wget / curl 下载下来的也是 json 描述文件,而不是源文件本身。

    请问我要如何使用 wget / curl 到 github 下载源文件呢

    10 条回复    2024-02-07 21:58:56 +08:00
    Rnreck
        2
    Rnreck  
       80 天前
    @Alias4ck #1 400: Invalid request
    Alias4ck
        3
    Alias4ck  
       80 天前
    4ark
        4
    4ark  
       80 天前 via iPhone
    页面有个链接可以直接打开 raw 的,保存就是了
    fioncat
        5
    fioncat  
       80 天前
    把你链接里面的 github.com 域名换成 raw.githubusercontent.com

    PS. 该域名在国内经常存在 DNS 污染的问题,建议挂梯子使用。
    hukei
        6
    hukei  
       80 天前
    应该见过很多分享的一键执行脚本用的这个地址的吧 raw.githubusercontent.com
    Rnreck
        7
    Rnreck  
       80 天前
    @Alias4ck #3 抱歉,一开始确实没仔细看,直接点进去了,然后根据 return 回复你了,那是实在有点不清醒,非常抱歉,,,,后面又试了一下 curl 能用,wget 显示 Unable to establish SSL connection. 这个情况,更新下 openssl 搞定了
    henix
        8
    henix  
       80 天前
    beyondstars
        9
    beyondstars  
       80 天前   ❤️ 1
    您好,加一个 'Accept' 参数即可:

    curl -L -H 'accept: application/vnd.github.raw' https://api.github.com/repos/fivethirtyeight/data/contents/ahca-polls/ahca_polls.csv
    beyondstars
        10
    beyondstars  
       80 天前   ❤️ 1
    对于不同的 accept 参数值,可以获取到不同的格式。参见 github api doc 对 media types 的定义: https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#media-types
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1312 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:39 · PVG 01:39 · LAX 10:39 · JFK 13:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.