-->

Get random term page from a specific category with

2019-06-13 18:59发布

问题:

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).