从Github API获取特定的README.md数据 [英] Get specific README.md data from Github API

查看:440
本文介绍了从Github API获取特定的README.md数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始尝试使用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!

API:反应README.md API数据

公共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数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆