wptools icon indicating copy to clipboard operation
wptools copied to clipboard

Get category tree structure

Open 67yuhjnm opened this issue 7 years ago • 2 comments

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

67yuhjnm avatar Jan 22 '18 07:01 67yuhjnm

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!

siznax avatar Jan 23 '18 23:01 siznax

OK, thanks to your explanation and suggestion.

67yuhjnm avatar Jan 24 '18 03:01 67yuhjnm