A really simple MediaWiki API client.
Can use most MediaWiki API modules.
Requires the requests library.
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.
Metadata
Release files for mw-api-client 3.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mw-api-client-3.2.2.tar.gz | 22.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mw_api_client-3.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.8 kB
Release files / mw-api-client-3.2.2.tar.gz
| Download URL | mw-api-client-3.2.2.tar.gz |
|---|---|
| Size | 22.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7375996156d7f4957d11886141add846ab049dfa73a29eacd11a496965cc1270
|
|
BLAKE2b-256 checksum How to use checksums |
f507b161d96acd1757d1bd653c04b4879dfc182bf42aaf3dcfdd9a7aee1e6582
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / mw_api_client-3.2.2-py3-none-any.whl
| Download URL | mw_api_client-3.2.2-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
799a7c4426bab827e93910e998fae19534758592171cb615ce182e472953e961
|
|
BLAKE2b-256 checksum How to use checksums |
3e0d92586e9f8e481ee35db4bcf624e18c324536ae73e8373effab84e8ebd3bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|