如何使用维基百科的 API 获取维基百科内容? [英] How can I get Wikipedia content using Wikipedia's API?
本文介绍了如何使用维基百科的 API 获取维基百科内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取维基百科文章的第一段.
I want to get the first paragraph of a Wikipedia article.
这样做的 API 查询是什么?
What is the API query to do so?
推荐答案
在 MediaWiki 文档.
这些是关键参数.
prop=revisions&rvprop=content&rvsection=0
rvsection = 0 指定只返回前导部分.
rvsection = 0 specifies to only return the lead section.
看这个例子.
要获取 HTML,您可以类似地使用 action=parsehttp://en.wikipedia.org/w/api.php?action=parse§ion=0&prop=text&page=pizza
To get the HTML, you can use similarly use action=parse http://en.wikipedia.org/w/api.php?action=parse§ion=0&prop=text&page=pizza
请注意,您必须删除任何模板或信息框.
Note that you'll have to strip out any templates or infoboxes.
这篇关于如何使用维基百科的 API 获取维基百科内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文