-
Waldir authored
Semantic linebreaks: http://rhodesmill.org/brandon/2012/one-sentence-per-line/
Waldir authoredSemantic linebreaks: http://rhodesmill.org/brandon/2012/one-sentence-per-line/
This file is intended to be a reference to mwclient. The current version is mwclient 0.6.6.
The mwclient framework provides an access to the MediaWiki API. It provides the functions of the MediaWiki API in a Pythonic manner.
Sites
The Site
object is the most important class.
It represents a MediaWiki site.
Its constructor accepts various arguments,
of which the first two, host
and path
, are the most important.
They represent respectively
the hostname without protocol
and the root directory where api.php
is located.
The path parameter should end with a slash, /.
Protocols other than HTTP are currently not supported.
site = mwclient.Site(host, path = '/w/', ...)
Pages
Sites provide access to pages via various generators and the Pages object.
The base Page object is called Page
and from that derive Category and Image.
When the page is retrieved via Site.Pages
or a generator,
it will check automatically which of those three specific types
should be returned.
To get a page by its name, call Site.Pages
as a scriptable object:
page = site.Pages['Template:Stub']
image = site.Pages['Image:Wiki.png'] # This will return an Image object
image2 = site.Images['Wiki.png'] # The same image
Alternatively, Site.Images
and Site.Categories
are provided,
which do exactly the same as Site.Pages
,
except that they require the page name without its namespace prefixed.