Get category tree structure
Hello,
Wikipedia has a special page, called Special:CategoryTree.
We can obtain the all categories based on a tree structure online by clicking the category, such as Special:CategoryTree?target=Category:Contents
Is it possible to download all the tree nodes (category names) and the node relationships (the relationships between categories and subcategories) to the local by the Wikipedia API? Can wptools accomplish this function?
Thanks in advance
Thanks for the question, @67yuhjnm. Extension:CategoryTree does not seem to be part of the Wikimedia API.
You could accomplish the same thing by recursively getting all members of all subcategories with wptools, basically crawling the wiki's categories. If this issue generates a lot of interest, then maybe we can start adding "crawler" features like that, but at this point the XML dumps may be your best option.
Alternatively, you could open a phabricator ticket to have Extension:CategoryTree added to the MediaWiki API. If you find an entrypoint for it at some point, please let us know!
OK, thanks to your explanation and suggestion.