Skip to main content

A simple MediaWiki client.

Project description

A really simple MediaWiki API client.

Can:

  • read pages

  • edit pages

  • list pages in category

  • list page backlinks (“what links here”)

  • list page transclusions

Requires the requests library.

http://www.mediawiki.org/

Example Usage

Get a page:

wiki = Wiki("https://en.wikipedia.org/", "wiki/", "w/api.php")

wiki.login("kenny2wiki", password)

sandbox = wiki.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 wiki.category_members("Redirects"):
    print page.title

Remove all uses of a template:

target_pages = wiki.transclusions("Template:Stub")

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

# Main namespace only
target_pages = [p for p in target_pages if p.query_info()['ns'] == 0]

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

Made by Kenny2github, based on ~blob8108’s MWAPI client for the Scratch Wiki.

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-0.0.1.tar.gz (3.7 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-0.0.1-py2-none-any.whl (5.9 kB view details)

Uploaded Python 2

File details

Details for the file mw-api-client-0.0.1.tar.gz.

File metadata

  • Download URL: mw-api-client-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mw-api-client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9ad216a373b4b8c3175bac740cb22b46adf7ee3bf6ce908b0e48dd360fb0af40
MD5 64b89b79bd6b52d2dabb99d912ff6f70
BLAKE2b-256 28c20d007a06d5d89d9f517683ceecf231653eea6d9f9faf2313d41722ca11b3

See more details on using hashes here.

File details

Details for the file mw_api_client-0.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for mw_api_client-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 8087fee551ca294721100da85a830791cbe1d0be62e9e67b212f048bdb26a22e
MD5 4b6be28da6959c5c9b7fa73241602e60
BLAKE2b-256 3dcd2ee2d8a622827c687ee403fd8c5f5f16ed83f0294745766b941ce0e5b628

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