从MediaWiki API获取文章摘要 [英] Get an article summary from the MediaWiki API
问题描述
我正在寻找一个mediawiki api,通过它我可以获取有关任何查询字符串的简短描述.例如,如果我搜索尼古拉斯·凯奇(Nicolas Cage),它应该返回他的简短描述.
I am looking for a mediawiki api using which I can get short description about any query string. For example , if I search for Nicolas Cage then it should return the short description for him.
我不确定prop = revisions是否正确.我的目的是对页面的最终版本进行简短描述.
I am not sure if prop=revisions is right. My intention is to get a short description on the final version of the page.
我还需要另一个API,该API可以从查询字符串中提供Wikipedia页面(Web/移动设备)的链接.例如,对于Nicolas Cage,应返回 http://en.wikipedia.org/wiki/Nicolas_cage
Also I need another api which can give the link of the wikipedia page (web / mobile) from the query string. i.e. For Nicolas Cage, http://en.wikipedia.org/wiki/Nicolas_cage should be returned.
推荐答案
-
默认情况下,MediaWiki中没有页面摘要之类的内容,但是您可以像这样获得页面的第一段: PageSummaries ,则可以使用该扩展名来获取您的确切身份要求(例如在此示例中从扩展程序描述页面).
There is no such thing as a page summary in MediaWiki by default,but you can get the first paragraph of a page like this: http://en.wikipedia.org/w/api.php?action=parse&page=Nicolas_Cage&prop=text§ion=0
If the wiki has the extension PageSummaries installed, you can use that to get exactly what you are asking for (like in this example from the extension description page).
To find pages matching a string, you use the open search function, like this: http://en.wikipedia.org/w/api.php?action=opensearch&search=Nicolas%20cage&namespace=0
@Bergi在注释中指出,打开搜索还会提供该页面的摘要.我以某种方式错过了.
edit: @Bergi point out in the comments that open search also gives a summary of the page. I had somehow missed that.
这篇关于从MediaWiki API获取文章摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!