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>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀