问题描述
最近,我开始尝试使用GitHub API从公共存储库中获取特定数据.长话短说,我想从仓库中获取README.md文件的特定部分.
Recently, I started experimenting with the GitHub API getting specific data from public repos. Long story short, I want to grab specific parts of the README.md file from a repo.
例如,我想从Facebook的react存储库中的master分支获取GitHub API的 Documentation 标头下的文本.这可能吗?任何实现此目的的方法都是值得欢迎的.谢谢!
For example, the master branch from Facebook's react repository I want to grab the text under the Documentation header the GitHub API. Is this possible? Any methods of achieving this are welcome. Thank you!
公共Github URL:反应公共仓库
Public Github URL: React public repo
推荐答案
无法使用API进行此操作,但是一种简单的方法是使用sed
;.从Linux命令行尝试以下方法:
There is no way to do this with the API, but one easy way is with sed
; try this from a Linux command line:
curl https://raw.githubusercontent.com/facebook/react/master/README.md | \
sed -n '/## Documentation/,/##/p'
这将返回Documentation标题和下一个标题之间的所有内容.
This will return everything between the Documentation header and the next one.
这篇关于从Github API获取特定的README.md数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!