从MediaWiki API获取文章摘要 [英] Get an article summary from the MediaWiki API

查看:182
本文介绍了从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.

我尝试了 http://en.wikipedia.org/w/api.php?%20format=json&action=query&titles=Nicolas%20Cage&prop=revisions&rvprop=content

我不确定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.

推荐答案

  1. 默认情况下,MediaWiki中没有页面摘要之类的内容,但是您可以像这样获得页面的第一段: PageSummaries ,则可以使用该扩展名来获取您的确切身份要求(例如在此示例中从扩展程序描述页面).

  1. 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&section=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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆