Registry / devops / mwclient

mwclient

JSON →
library0.11.0pypypi✓ verified 83d ago

A lightweight, Pythonic client for the MediaWiki API. Version 0.11.0. Active development, irregular releases.

pip install mwclient
INSTALL
IMPORT
SIG · MWCLIENT
M
mwclient
devopspythonv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Site
import mwclient; site = mwclient.Site('en.wikipedia.org')
from mwclient import client; site = client.Site(...)
Top-level import is mwclient.Site; there is no mwclient.client submodule.
Page
from mwclient import Page
from mwclient.page import Page
Page is exposed at the mwclient package level, not from mwclient.page.

Connect to Wikipedia and fetch page text.

import mwclient site = mwclient.Site('en.wikipedia.org') page = site.pages['Python (programming language)'] print(page.text[:200])
Debug
Known issues
breakingIn v0.11.0, the `Site` constructor changed: `site = mwclient.Site('en.wikipedia.org')` works, but authenticating requires passing `(('username', 'password'),)` as a tuple inside a list for `clients_useragent`. Older code may break.
fix
Update credentials format: `site = mwclient.Site('en.wikipedia.org', clients_useragent=('MyBot',))`
affects: >=0.10.0
gotchamwclient does not automatically handle login. You must explicitly call `site.login(username, password)` before editing. Many new users expect automatic authentication.
fix
After creating a Site object, call `site.login(username, password)`.
affects: all
deprecatedThe `six` dependency is deprecated as of Python 3. Future versions may remove it. Ensure your code is Python 3 compatible.
fix
Use Python 3 string handling and avoid reliance on `six` internals.
affects: <=0.11.0
Errors
Common errors & fixes
mwclient.errors.LoginError: Login failed
Incorrect username/password or bot password not used.
fix
Ensure you are using a bot password (not your main password) and double-check credentials.
AttributeError: module 'mwclient' has no attribute 'client'
Importing from a non-existent submodule.
fix
Use `import mwclient; site = mwclient.Site(...)` instead of `from mwclient import client`.
requests.exceptions.ConnectionError: ... Name or service not known
Network issue or incorrect site URL.
fix
Verify site URL (e.g., 'en.wikipedia.org') and internet connection.
Upgrade
Version history
0.11.0latest on PyPI · released Aug 12, 2024
Audit
Dependencies
requestsrequiredUsed for HTTP requests.
sixrequiredUsed for Python 2/3 compatibility (deprecated in newer versions).
Agent activity
31 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
mwclient — pip install mwclient · libregistry