Find main category for article using Wikipedia API

╄→尐↘猪︶ㄣ 提交于 2019-12-04 13:33:07

First, there is no such thing as a "Wikipedia API". There is a MediaWiki (web) API. Knowing this will help you find information on the existing tools. https://www.mediawiki.org/wiki/API:Main_Page

Which tells you there is no API which will do all the category recursion for you. Why? Because 1) it's extremely inefficient, 2) the recursion might go anywhere or never end.

However there is a solution now, by Magnus Manske: https://tools.wmflabs.org/catscan2/reverse_tree.php?doit=1&language=en&project=wikipedia&title=Dog&namespace=0 "Maximum depth: 61 levels Total categories along the way : 7988" Using that definition, the "root" category for [[Dog]], i.e. the farthest father category, is "Industry by country". Probably not what you expected! However, from the English Wikipedia's perspective the root category for any article is always the same, [[Category:Contents]].

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!