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
=============
.. code-block:: python
import mw_api_client as mw
Get a page:
.. code-block:: python
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:
.. code-block:: python
# 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:
.. code-block:: python
for page in wp.category("Redirects").categorymembers():
print(page.title)
Remove all uses of a template:
.. code-block:: python
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:
.. code-block:: python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/Kenny2github/mw-api-client",
"name": "mw-api-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7",
"maintainer_email": "",
"keywords": "mediawiki api requests",
"author": "Ken Hilton",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/f5/07/b161d96acd1757d1bd653c04b4879dfc182bf42aaf3dcfdd9a7aee1e6582/mw-api-client-3.2.2.tar.gz",
"platform": null,
"description": "\r\nA really simple MediaWiki API client.\r\n\r\nCan use most MediaWiki API modules.\r\n\r\nRequires the ``requests`` library.\r\n\r\nhttp://www.mediawiki.org/\r\n\r\nInstallation\r\n============\r\n\r\nTo install the latest stable version::\r\n\r\n pip install -U mw-api-client\r\n\r\nTo install the latest development (likely unstable) version::\r\n\r\n git clone https://github.com/Kenny2github/mw-api-client.git\r\n cd mw-api-client\r\n python setup.py install\r\n\r\nExample Usage\r\n=============\r\n\r\n.. code-block:: python\r\n\r\n import mw_api_client as mw\r\n\r\nGet a page:\r\n\r\n.. code-block:: python\r\n\r\n wp = mw.Wiki(\"https://en.wikipedia.org/w/api.php\", \"MyCoolBot/0.0.0\")\r\n\r\n wp.login(\"kenny2wiki\", password)\r\n\r\n sandbox = wp.page(\"User:Kenny2wiki/sandbox\")\r\n\r\nEdit page:\r\n\r\n.. code-block:: python\r\n\r\n # Get the page\r\n contents = sandbox.read()\r\n\r\n # Change\r\n contents += \"\\n This is a test!\"\r\n summary = \"Made a test edit\"\r\n\r\n # Submit\r\n sandbox.edit(contents, summary)\r\n\r\nList pages in category:\r\n\r\n.. code-block:: python\r\n\r\n for page in wp.category(\"Redirects\").categorymembers():\r\n print(page.title)\r\n\r\nRemove all uses of a template:\r\n\r\n.. code-block:: python\r\n\r\n stub = wp.template(\"Stub\")\r\n\r\n # Pages that transclude stub, main namespace only\r\n target_pages = list(stub.transclusions(namespace=0))\r\n\r\n # Sort by title because it's prettier that way\r\n target_pages.sort(key=lambda p: p.title)\r\n\r\n for page in target_pages:\r\n page.replace(\"{{stub}}\", \"\")\r\n\r\nPatrol all recent changes in the Help namespace:\r\n\r\n.. code-block:: python\r\n\r\n rcs = wp.recentchanges(rcnamespace=12)\r\n\r\n for rc in rcs:\r\n rc.patrol()\r\n\r\n\r\nMade by Kenny2github, based off of ~blob8108's Scratch Wiki API client.\r\n\r\nMIT Licensed.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple MediaWiki client.",
"version": "3.2.2",
"project_urls": {
"Homepage": "https://github.com/Kenny2github/mw-api-client"
},
"split_keywords": [
"mediawiki",
"api",
"requests"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e0d92586e9f8e481ee35db4bcf624e18c324536ae73e8373effab84e8ebd3bd",
"md5": "9b326cb5d3ec5b9297dccc0b5c0d4b4d",
"sha256": "799a7c4426bab827e93910e998fae19534758592171cb615ce182e472953e961"
},
"downloads": -1,
"filename": "mw_api_client-3.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9b326cb5d3ec5b9297dccc0b5c0d4b4d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=2.7",
"size": 25229,
"upload_time": "2023-12-12T12:42:17",
"upload_time_iso_8601": "2023-12-12T12:42:17.745873Z",
"url": "https://files.pythonhosted.org/packages/3e/0d/92586e9f8e481ee35db4bcf624e18c324536ae73e8373effab84e8ebd3bd/mw_api_client-3.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f507b161d96acd1757d1bd653c04b4879dfc182bf42aaf3dcfdd9a7aee1e6582",
"md5": "520d8da069a94aa325b73f93d0f26fd3",
"sha256": "7375996156d7f4957d11886141add846ab049dfa73a29eacd11a496965cc1270"
},
"downloads": -1,
"filename": "mw-api-client-3.2.2.tar.gz",
"has_sig": false,
"md5_digest": "520d8da069a94aa325b73f93d0f26fd3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 22620,
"upload_time": "2023-12-12T12:42:19",
"upload_time_iso_8601": "2023-12-12T12:42:19.483724Z",
"url": "https://files.pythonhosted.org/packages/f5/07/b161d96acd1757d1bd653c04b4879dfc182bf42aaf3dcfdd9a7aee1e6582/mw-api-client-3.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-12 12:42:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Kenny2github",
"github_project": "mw-api-client",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "six",
"specs": []
}
],
"lcname": "mw-api-client"
}