Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created November 22, 2011 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save junaidpv/1385448 to your computer and use it in GitHub Desktop.
Save junaidpv/1385448 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
@author Junaid
"""
import wikipedia
import catlib
wiki = 'wikipedia'
lang = 'ml'
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