prop=extracts 不返回维基媒体 API 中的所有摘录 [英] prop=extracts not returning all extracts in the WikiMedia API

查看:23
本文介绍了prop=extracts 不返回维基媒体 API 中的所有摘录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 维基百科 API 返回多篇维基百科文章的摘录立刻.例如,我正在尝试以下请求(我只是随机选择了 pageid):

I would like to use the wikipedia API to return the extract from multiple wikipedia articles at once. I am trying, for example, the following request (I just chose the pageids randomly):

http://en.wikipedia.org/w/api.php?format=xml&action=query&pageids=3258248|11524059&prop=extracts&exsentences=1

但它只包含第一个 pageid 的摘录,而不包含第二个.其他属性似乎没有这个限制.例如

But it only contains the extract for the first pageid, and not the second. Other properties seem not to have this limitation. For example

http://en.wikipedia.org/w/api.php?format=xml&action=query&pageids=3258248|11524059&prop=categories

将返回两个 pageid 的类别.这是一个错误,还是我遗漏了什么?

will return the categories for both pageids. Is this a bug, or am I missing something?

推荐答案

注意 元素.它告诉你要获得更多的提取物,你需要指定 excontinue=1:

Notice the <query-continue> element. It tells you that to get more of the extracts, you need to specify excontinue=1:

http://en.wikipedia.org/w/api.php?format=xml&action=query&pageids=3258248|11524059&prop=extracts&exsentences=1&excontinue=1

通过指定exlimit=max,您应该能够同时获得它们:

You should be able to get both of them, by specifying exlimit=max:

http://en.wikipedia.org/w/api.php?format=xml&action=query&pageids=3258248|11524059&prop=extracts&exsentences=1&exlimit=max

但这似乎不能正常工作,我不知道为什么.

But this does not seem to work correctly, I'm not sure why.

顺便说一句,类别有类似的限制,这就是为什么您的类别查询也有 <query-continue> 以及为什么它没有列出文章的所有类别.

BTW, categories have similar limitations, which is why your categories query has <query-continue> too and why it doesn't list all categories of the articles.

这篇关于prop=extracts 不返回维基媒体 API 中的所有摘录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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