Site.Categories

Waldir Pimenta edited this page May 31, 2014 · 2 revisions
Clone this wiki locally

Site.Categories is a PageList object that provides access to the Category object for any category on a site, as in:

page = site.Categories['Apples']
text = page.[[Page.edit|edit]]()

When using Categories, unlike when using Site.Pages, the "Category:" namespace prefix is not required.

It also permits iteration over all categories on a site:

for page in site.Categories:
    print page.[[Page.page_title|page_title]]

For a large site with many categories, this kind of loop can take a long time to run.

To access other types of pages, use Site.Pages or Site.Images.


This page was originally imported from the old mwclient wiki at SourceForge. The imported version was dated from 09:16, 25 November 2011, and its only editor was Derrickcoetzee (@dcoetzee).