How to get all subcategories from a category page on Wikipedia using the Wikipedia API?

Possible duplicate:
How to get all the articles in the Wikipedia section and its subcategories

So, I am doing a PHP project for fun, which involves extracting a random element from a specific category on Wikipedia. For example, say I want a random weapon: my program goes to http://en.wikipedia.org/wiki/ Category: Weapons and selects a subcategory at random (say Category: Toy weapons ), then continues to choose a lower level of subcategory until will not reach an article that is not a category (ex: Super Soaker ).

However, I am having problems getting a list of subcategories from this category. I know that I can get the categories to which the article belongs, but how can I do the opposite (extract pages with a specific category)?

Thank.

+3
source share
1 answer

you should receive the following request

?

api.php action = query & list = categorymembers & cmtitle = Category: Weapons

+7
source

Source: https://habr.com/ru/post/1785065/


All Articles