How do I get all the sub-categories from a Category page on Wikipedia, using the Wikipedia API? [duplicate]
Possible Duplicate:
How to get all article pages under a Wikipedia Category and its sub-categories
So I'm making a PHP project for fun that involves pulling out a random item from a set category on Wikipedia. For example, say I want a random weapon : my program goes to http://en.wikipedia.org/wiki/Category:Weapons and picks a sub-category at random (say Category:Toy weapons), then keeps picking a lower level of sub-category until it reaches an article that isn't a category (for example : Super Soaker).
However, I'm having problems getting a list of sub-categories from a given category. I know I can get the categories an article belongs to, but how can I do the opposite (extract the pages that have a specific category) ?
Thanks.
you should get is using following query
api.php?action=query&list=categorymembers&cmtitle=Category:Weapons
精彩评论