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
python setup.py install

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(rcnamespace=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.2.0a3.tar.gz (21.6 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.2.0a3-py2.py3-none-any.whl (25.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mw-api-client-3.2.0a3.tar.gz.

File metadata

  • Download URL: mw-api-client-3.2.0a3.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.0

File hashes

Hashes for mw-api-client-3.2.0a3.tar.gz
Algorithm Hash digest
SHA256 5757c284a93c9b9345aaf0f57f8d9ff90686cc958e5d0f0a796fb824adae6c74
MD5 0f94cb739f957039d1885faca365c4af
BLAKE2b-256 8faa028ab4efb184773c24f97d1677624fb729156f0e3e1592b41eff13d01024

See more details on using hashes here.

File details

Details for the file mw_api_client-3.2.0a3-py2.py3-none-any.whl.

File metadata

  • Download URL: mw_api_client-3.2.0a3-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.0

File hashes

Hashes for mw_api_client-3.2.0a3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 16b7dede3558f01f9164308cf1e4477a30fa659167679c10381fb3ec57f426b2
MD5 27f8a1a7475d72b9dedd6224400e1b37
BLAKE2b-256 d2184b939bbc505d1f93b1ffe7050e317dd4817d1af24e627850b7a8c7e3b4ab

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