如何下载gists的文件?


缘由:

有不少人使用gists作为他们的代码仓库,而不是GitHub上的repository,但是gists又被墙掉了(想安静地下载个代码怎么就这么困难呢?),作为一个以看好代码为爱好的我得想办法解决一下这个问题,于是有了下文。

搜索关键字:
  • Get all gists of a GitHub user
  • Get all gists of a GitHub user site:stackoverflow.com
参考链接:
参考解答:

获取某个user的所有公开gists:https://api.github.com/users/koraktor/gists

获取某个特定id的gists:https://api.github.com/gists/1092043

然后通过解析返回的json内容,获取对应id的raw_url,然后直接wget下来就行了。

==

想要通过脚本实现的功能有:
  1. 给定gists的id,然后自动下载其中涉及到的所有文件;
  2. 给定gists的username,得到该用户所有的public gists;
  3. 了解最近最火的gists有哪些。

==

可能需要注意的几个问题:

{#文件格式

application/vnd.github.VERSION.raw

application/vnd.github.VERSION.base64

}

{#存放名称

新建目录:$user_$id

新建描述文件:$id_$description.txt

}

{#下载速度的控制

可以参考:

https://raw.githubusercontent.com/lijiejie/GitHack/master/GitHack.py

}

https://gist.githubusercontent.com/fedir/5466075/raw/d3f47664c0fcf40fd18698c9031cda6bfda3fb8b/gist-backup.py

中的做法——多线程下载gists中出现的 “files” -> “raw_url” 。

=EOF=


《 “如何下载gists的文件?” 》 有 3 条评论

回复 a-z 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注