开发者

How do I get all the sub-categories from a Category page on Wikipedia, using the Wikipedia API? [duplicate]

开发者 https://www.devze.com 2023-02-04 21:36 出处:网络
This question already has answers here: Closed 11 years ago. 开发者_StackOverflow社区 Possible Duplicate:
This question already has answers here: Closed 11 years ago. 开发者_StackOverflow社区

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

0

精彩评论

暂无评论...
验证码 换一张
取 消