pbespechnyi
pbespechnyi

Reputation: 2291

How to get random page of specific "Portal:" using WikiMedia API

Is there any way to get random article of specific wikimedia portal using wikimedia API?

For example, I need random page of Portal:Science.

Does anyone know how to do this?

Upvotes: 1

Views: 2344

Answers (1)

svick
svick

Reputation: 244797

What you're asking for doesn't make much sense, because a portal doesn't have a list of pages associated with it.

The closest thing you can do is to get a random page from e.g. Category:Science or one of its subcategories. There is no way to do that directly using the API, you would need to traverse all the subcategories and choose a random page from them by yourself.

There is a tool that already does this (with a limit on the depth of the category tree): erwin85's random article and there is also a template for it on the English Wikipedia.

Upvotes: 4

Related Questions