Page

danmichaelo edited this page Sep 21, 2014 · 5 revisions
Clone this wiki locally

A Page object represents a page on a site, including mainspace pages, project pages, category and file description pages, interface pages, and so on. It has two subclasses, Category and Image, for categories and files in particular. Page objects are most easily retrieved from the Site.Pages collection:

page = site.Pages['Apple']

Once retrieved, the most common operation to perform with a page is to edit it, as in this example that moves a page from one category to another:

text = page.text()
text = text.replace('<nowiki>[[Category:Apples]]</nowiki>', '<nowiki>[[Category:Pears]]</nowiki>')
page.save(text, summary='Moved from category Apples to category Pears')

Deletion, moving, and purging of pages is also supported. Many lists related to a page can be retrieved, such as links to and from a page, categories, and the revision history. Many properties of the page are available through its public data members.

Method reference

List methods

Internal methods

Data member reference


This page was originally imported from the old mwclient wiki at SourceForge. The imported version was dated from 01:54, 6 February 2012, and its only editor was Derrickcoetzee (@dcoetzee).