-
-
Save oligoglot/4e1fd25a601e3560c10f7cdbd8804dd0 to your computer and use it in GitHub Desktop.
Count all pages within a category and its sub-categories recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Description | |
Count all pages within a category and its sub-categories recursively | |
Modifying Junaid's code with a Tamil Wiki example. | |
@author Junaid, Sundar | |
""" | |
import wikipedia | |
import catlib | |
wiki = 'wikipedia' | |
lang = 'ta' | |
cat_title = ur'பகுப்பு:சூழியல்' | |
site = wikipedia.Site(code=lang, fam=wiki) | |
cat = catlib.Category(site=site, title=cat_title) | |
count = len(cat.articlesList(recurse=True)) | |
print "Number of articles in the category: ", count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment