维基百科 API 摘录返回文本中的编辑链接



我正在尝试从维基百科API中提取json。 当我提取主要内容时,它会显示在我的页面上,但编辑链接显示在<h2>标题旁边。 我已经包括了参数"disableeditsection": false,既truefalse但无济于事。 根据这些文档:文档

关于如何从摘录中删除'edit'文本的任何想法?

提前感谢您的帮助

$(document).ready(function ($) {
    console.log('ready1!');
    var wikiSearch = "Blue Spring State Park";
    var queryURL = "https://en.wikipedia.org/w/api.php";
    var params = {
        "disableeditsection": false,
        "action": "query",
        "format": "json",
        "prop": "links|images|extlinks|imageinfo|info|url|extracts|text",
        "iiprop": "timestamp|user|url|comment",
        "meta": "url",
        "origin": "*",
        "iwurl": 1,
        "titles": wikiSearch,
        "redirects": 1,
        "inprop": "url"
    };
    queryURL += "?" + $.param(params);
    $.ajax({
        url: queryURL,
        method: "GET"
    }).done(function (response) {
        console.log('ready2!');
        console.log('response', response);
        var objResult = response
        console.log(objResult);
        $.each(response.query.pages, function (c) {
            var hey = response.query.pages[c].extract;
            $("#wikipediaImages").html(hey);
        }); //End .each
    }); //End .done
}); //End Document.ready

您似乎使用了 extract 的输出。这通常不包括编辑链接。但是某些页面上似乎存在错误。禁用编辑部分不适用于prop=extracts

如果您希望 html 保持原样,而不对部分链接进行编辑,请使用操作解析:https://en.wikipedia.org/w/api.php?action=parse&format=json&page=Blue%20Spring%20State%20Park&disableeditsection=1

一般来说,您的问题不清楚到底要显示什么。

最新更新