Page

class mwclient.page.Page(site, name, info=None, extra_properties=None)[source]

List pages that link to the current page, similar to Special:Whatlinkshere.

API doc: https://www.mediawiki.org/wiki/API:Backlinks

can(action)[source]

Check if the current user has the right to carry out some action with the current page.

>>> page.can('edit')
True
categories(generator=True)[source]

List categories used on the current page.

API doc: https://www.mediawiki.org/wiki/API:Categories

delete(reason='', watch=False, unwatch=False, oldimage=False)[source]

Delete page.

If user does not have permission to delete page, an InsufficientPermission exception is raised.

edit(*args, **kwargs)[source]

Deprecated. Use page.text() instead

embeddedin(namespace=None, filterredir='all', limit=None, generator=True)[source]

List pages that transclude the current page.

API doc: https://www.mediawiki.org/wiki/API:Embeddedin

Parameters:
  • namespace (int) – Restricts search to a given namespace (Default: None)
  • filterredir (str) – How to filter redirects, either ‘all’ (default), ‘redirects’ or ‘nonredirects’.
  • limit (int) – Maximum amount of pages to return per request
  • generator (bool) – Use generator
Returns:

Page iterator

Return type:

mwclient.listings.List

List external links from the current page.

API doc: https://www.mediawiki.org/wiki/API:Extlinks

get_expanded()[source]

Deprecated. Use page.text(expandtemplates=True) instead

images(generator=True)[source]

List files/images embedded in the current page.

API doc: https://www.mediawiki.org/wiki/API:Images

List interwiki links from the current page.

API doc: https://www.mediawiki.org/wiki/API:Iwlinks

List interlanguage links from the current page.

API doc: https://www.mediawiki.org/wiki/API:Langlinks

List links to other pages from the current page.

API doc: https://www.mediawiki.org/wiki/API:Links

move(new_title, reason='', move_talk=True, no_redirect=False)[source]

Move (rename) page to new_title.

If user account is an administrator, specify no_redirect as True to not leave a redirect.

If user does not have permission to move page, an InsufficientPermission exception is raised.

purge()[source]

Purge server-side cache of page. This will re-render templates and other dynamic content.

redirects_to()[source]

Returns the redirect target page, or None if the page is not a redirect page.

resolve_redirect()[source]

Returns the redirect target page, or the current page if it’s not a redirect page.

revisions(startid=None, endid=None, start=None, end=None, dir='older', user=None, excludeuser=None, limit=50, prop='ids|timestamp|flags|comment|user', expandtemplates=False, section=None)[source]

List revisions of the current page.

API doc: https://www.mediawiki.org/wiki/API:Revisions

Parameters:
  • startid (int) – Revision ID to start listing from.
  • endid (int) – Revision ID to stop listing at.
  • start (str) – Timestamp to start listing from.
  • end (str) – Timestamp to end listing at.
  • dir (str) – Direction to list in: ‘older’ (default) or ‘newer’.
  • user (str) – Only list revisions made by this user.
  • excludeuser (str) – Exclude revisions made by this user.
  • limit (int) – The maximum number of revisions to return per request.
  • prop (str) – Which properties to get for each revision, default: ‘ids|timestamp|flags|comment|user’
  • expandtemplates (bool) – Expand templates in rvprop=content output
  • section (int) – If rvprop=content is set, only retrieve the contents of this section.
Returns:

Revision iterator

Return type:

mwclient.listings.List

save(text, summary=u'', minor=False, bot=True, section=None, **kwargs)[source]

Update the text of a section or the whole page by performing an edit operation.

templates(namespace=None, generator=True)[source]

List templates used on the current page.

API doc: https://www.mediawiki.org/wiki/API:Templates

text(section=None, expandtemplates=False)[source]

Get the current wikitext of the page, or of a specific section. If the page does not exist, an empty string is returned.

Parameters:
  • section (int) – numbered section or None to get the whole page (default: None)
  • expandtemplates (bool) – set to True to expand templates (default: False)