MediaWiki API:从生成器返回的结果少于默认值10

时间:2015-06-03 21:15:37

标签: api search limit mediawiki-api

以下链接返回10页的信息。

http://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=Skydive&format=json&gsrprop=snippet&prop=info&inprop=url&rawcontinue

如何让此查询只返回一页的信息?

将ptlimit,cmlimit,ect ...设置为1会给我以下错误。

Unrecognized parameter ptlimit

gsroffset默认为10.我尝试将此参数放入查询中,但它只是添加了我放到10的数字。

1 个答案:

答案 0 :(得分:0)

您使用了generator=search,因此您必须检查API:Search中您发现它的名称srlimit;前缀为g,因为您将其用作generator,这会产生gsrlimit=1

https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=Skydive&format=json&gsrprop=snippet&prop=info&inprop=url&rawcontinue&gsrlimit=1

{"query-continue":{"search":{"gsroffset":1}},"query":{"pages":{"19723982":{"pageid":19723982,"ns":0,"title":"Parachuting","index":1,"contentmodel":"wikitext","pagelanguage":"en","touched":"2015-07-21T16:28:32Z","lastrevid":670810888,"length":44466,"fullurl":"https://en.wikipedia.org/wiki/Parachuting","editurl":"https://en.wikipedia.org/w/index.php?title=Parachuting&action=edit","canonicalurl":"https://en.wikipedia.org/wiki/Parachuting"}}}}