prop=extracts not returning all extracts in the WikiMedia API

浪尽此生 提交于 2019-12-21 06:14:43

问题


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

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

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


回答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

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.

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.



来源:https://stackoverflow.com/questions/9846795/prop-extracts-not-returning-all-extracts-in-the-wikimedia-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!