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())
深入
Metadata
Release files for mwbot 1.0.42
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mwbot-1.0.42.tar.gz | 10.1 kB | Without provenance | Details for mwbot-1.0.42.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mwbot-1.0.42-py3-none-any.whl | Python 3 | none | any | Details for mwbot-1.0.42-py3-none-any.whl |
Total release size: 21.8 kB
Release files / mwbot-1.0.42.tar.gz
| Download URL | mwbot-1.0.42.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b66892cc3428991d2e3b02f00fee56b15cea960a68569c01d892413752f332b
|
|
BLAKE2b-256 checksum How to use checksums |
3064cf4f72d84a643c84ae02e3cf7b7da08f9f07292bc04be47157c41c8075a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.25.9 CPython/3.12.3 Linux/6.11.0-1018-azure
|
Release files / mwbot-1.0.42-py3-none-any.whl
| Download URL | mwbot-1.0.42-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbd31ca7339784d8529c73ade307f6661967eb5756638815946b8cab1ea139ec
|
|
BLAKE2b-256 checksum How to use checksums |
cc720087bb4f3dd46a9d0238050375ecfc320420ee60089b9fdf960669e00179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.25.9 CPython/3.12.3 Linux/6.11.0-1018-azure
|
Security for mwbot 1.0.42
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.