Skip to main content

A simple MediaWiki client.

Project description

A really simple MediaWiki API client.

Can use most MediaWiki API modules.

Requires the requests library.

http://www.mediawiki.org/

Installation

To install the latest stable version:

pip install -U mw-api-client

To install the latest development (likely unstable) version:

git clone https://github.com/Kenny2github/mw-api-client.git
cd mw-api-client
pip install -e .

Example Usage

import mw_api_client as mw

Get a page:

wp = mw.Wiki("https://en.wikipedia.org/w/api.php", "MyCoolBot/0.0.0")

wp.login("kenny2wiki", password)

sandbox = wp.page("User:Kenny2wiki/sandbox")

Edit page:

# Get the page
contents = sandbox.read()

# Change
contents += "\n This is a test!"
summary = "Made a test edit"

# Submit
sandbox.edit(contents, summary)

List pages in category:

for page in wp.category("Redirects").categorymembers():
    print(page.title)

Remove all uses of a template:

stub = wp.template("Stub")

# Pages that transclude stub, main namespace only
target_pages = list(stub.transclusions(namespace=0))

# Sort by title because it's prettier that way
target_pages.sort(key=lambda p: p.title)

for page in target_pages:
    page.replace("{{stub}}", "")

Patrol all recent changes in the Help namespace:

rcs = wp.recentchanges(namespace=12)

for rc in rcs:
    rc.patrol()

Made by Kenny2github, based off of ~blob8108’s Scratch Wiki API client.

MIT Licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mw-api-client-3.0.0rc2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mw_api_client-3.0.0rc2-py2.py3-none-any.whl (21.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mw-api-client-3.0.0rc2.tar.gz.

File metadata

File hashes

Hashes for mw-api-client-3.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 4e3ca6246f62d11d9de75f4b9f479d7985963117557fcdded376c23b754c1ddb
MD5 faaa14038684c1a8218491c8b33c0c40
BLAKE2b-256 153fd01ead4e7fc414f5db50b468220ffd2a7dd9c39c6a154b77e88bb23511d2

See more details on using hashes here.

File details

Details for the file mw_api_client-3.0.0rc2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mw_api_client-3.0.0rc2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bec2b39a100f84eb84283db579f3955ed4d00bbf89299a199b78cda9cab5fb14
MD5 86a4b086fd4768faadf49694fb5616b8
BLAKE2b-256 857a8245c1fa5bf441cf6346f4cd1b82799f49790074f1f5e304d84b9ce987e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page