Skip to content

Instantly share code, notes, and snippets.

@oligoglot
Forked from junaidpv/cat-all-pages-count.py
Last active November 27, 2016 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oligoglot/4e1fd25a601e3560c10f7cdbd8804dd0 to your computer and use it in GitHub Desktop.
Save oligoglot/4e1fd25a601e3560c10f7cdbd8804dd0 to your computer and use it in GitHub Desktop.
Count all pages within a category and its sub-categories recursively
# -*- 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