个性化封装的Python Mediawiki API库
Project description
mwbot(Python)
mwbot是一个基于Python的异步 Mediawiki API库,同时封装了用于PRTS wiki的部分方法
快速使用
前备工作
安装
pip install mwbot -i https://pypi.org/simple/
获取Bot应有的参数
- 前往对应wiki的 特殊:版本 页面获取wiki的index.php, api.php的路径
- 前往对应wiki的 特殊:BotPasswords 创建一套机器人密码
详细过程
-
填入“机器人名称”。(如:BotName)
-
选择下方的权限
- 这将能够限制通过机器人密码登录后的账户权限,尤其是当你的人工账户和机器人是同一账户时,这将有效保护你的账户。
- bot只能使用您选中的与您拥有的权限的交集。
-
创建成功,获得机器人密码,你将有两种登录机器人的方式,任意一种都能登录至机器人账户:
- 登录名为User@BotName,密码为BotPassword
- 登录名为User,密码为BotName@BotPassword
开始使用
from mwbot import Bot
import asyncio
async def main():
bot = Bot(
sitename="my_wiki", # 替换为你所在的Wiki名,便于参考
api="api", # 替换为对应Wiki的api.php路径
index="index", #替换为对应Wiki的index.php路径
username="User",
password="BotName@BotPassword")
# 将username和password替换为你刚才获得的机器人登录名和密码
# 你只能选择一种登录方式,并填入对应登录方式的登录名和密码
await bot.login()
# 样例:打印页面 用户:User 的内容
r = await bot.get_page_text(title="用户:User")
print(r)
if __name__ == "__main__":
asyncio.run(main())
深入
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mwbot-1.0.38.tar.gz
(9.8 kB
view details)
Built Distribution
mwbot-1.0.38-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file mwbot-1.0.38.tar.gz
.
File metadata
- Download URL: mwbot-1.0.38.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.17.2 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31350b7f33d7627bc965759c38cf0ee05256aec066ee8b52bc91fd97a53839ac |
|
MD5 | e8d900f5eb99087137705684cedcc9a7 |
|
BLAKE2b-256 | 5f50a7f8224718a727951a51c00568ac8d00d4f3179cc52eec8998e3e84a2d70 |
File details
Details for the file mwbot-1.0.38-py3-none-any.whl
.
File metadata
- Download URL: mwbot-1.0.38-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.17.2 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ace121afe211271d4d982b83d9be5c029077a36a2952fed7bb567e22eb43bc8 |
|
MD5 | 3ae180858236b91cc459ef503ac59eab |
|
BLAKE2b-256 | 32a69ba47474e9cd12b2cba3f60e608eb90a9de1dcaf03bf94da95298202f133 |