Get random term page from a specific category with wiki api

家住魔仙堡 提交于 2019-12-08 10:13:54

问题


I am trying to get a random term article from the wikipedia. The API:Random page lists only three parameters I can pass to the request. None of them seem to do what I want to achieve.

My question is - is it possible to get a random article from a specified category and is it possible to get a term page.
Example of what I mean by saying a "term" article - subtraction, reciprocity, api (I can't link the last two because I don't have enough rep).

Thanks


回答1:


Well yes, but not through the proper API. There is a special page in MediaWiki that allows for something like this: https://en.wikipedia.org/wiki/Special:RandomInCategory

However, it does not take parameters. But there is also this tool: http://tools.wmflabs.org/magnustools/randomarticle.php which will do the trick.

It will allow parameters like in this example: http://tools.wmflabs.org/magnustools/randomarticle.php?lang=en&project=wikipedia&categories=Pop+music&d=3

lang is the language of the Wikipedia you want (in this case en for English), with project you could use other projects (like Wikibooks or Wikiquote), categories is what you are looking for and d can be used if you want to look in the subcategories of that category (to that level).



来源:https://stackoverflow.com/questions/28520429/get-random-term-page-from-a-specific-category-with-wiki-api

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