如何使用维基百科 API 获取全文文本?
How to get full article as text using Wikipedia API?
我正在使用此代码来获取文章,但它只包含文本片段:
$.ajax({
url: "https://en.wikipedia.org/w/api.php?",
data: {
action: 'query',
list: 'search',
srsearch: "Richard Stallman",
format: 'json'
},
dataType: 'jsonp',
success: function(data){
var datatp = '';
data.query.search.map(function(f) {
datatp += '<h3>' + f.title + '</h3>';
datatp += f.snippet;
});
resultDiv.html(datatp);
}
});
我发现了这个问题:How to get Wikipedia content using Wikipedia's API? but it show how to fetch first paragraph of the article in wiki markup. How can I fetch full article as text? I can live with wiki content I can figure out how to remove it from the text. JSFIDDLE
你从那个问题中得到答案,并省略了特定的 rvsection 参数。例如,
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=pizza
我正在使用此代码来获取文章,但它只包含文本片段:
$.ajax({
url: "https://en.wikipedia.org/w/api.php?",
data: {
action: 'query',
list: 'search',
srsearch: "Richard Stallman",
format: 'json'
},
dataType: 'jsonp',
success: function(data){
var datatp = '';
data.query.search.map(function(f) {
datatp += '<h3>' + f.title + '</h3>';
datatp += f.snippet;
});
resultDiv.html(datatp);
}
});
我发现了这个问题:How to get Wikipedia content using Wikipedia's API? but it show how to fetch first paragraph of the article in wiki markup. How can I fetch full article as text? I can live with wiki content I can figure out how to remove it from the text. JSFIDDLE
你从那个问题中得到答案,并省略了特定的 rvsection 参数。例如,
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=pizza