DragonWar% 2015-06-21 23:58 采纳率: 0%
浏览 39

检索自述文件的HTML

Hi so first time working with APIs like this. Anyways, I've been reading up on the GitHub API and came across this:

READMEs support custom media types for retrieving the raw content or rendered HTML.

src: https://developer.github.com/v3/repos/contents/#get-the-readme

Which I believe means that it is possible to retrieve an HTML formatted version of the contents of the README? If so how would I retrieve it using AJAX since the tutorials are all for curl. In the end I want to display a portion of it on my website and would be a lot easier if given in the html format rather then markdown.

The docs say something about: application/vnd.github.VERSION.html

I just don't necessarily know how to use it.

Thanks!

  • 写回答

2条回答 默认 最新

  • 乱世@小熊 2015-06-22 00:18
    关注

    You have to set the Accept header of the HTTP request to application/vnd.github.html.

    $.ajax({
      url: 'https://api.github.com/repos/just95/toml.dart/readme',
      headers: { 'Accept': 'application/vnd.github.html' }
    }).done(function(data) {
      alert(data);
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问
  • ¥15 用MATLAB汇总拟合图
  • ¥15 智能除草机器人方案设计
  • ¥15 对接wps协作接口实现消息发送