Skip to main content

个性化封装的Python Mediawiki API库

Project description

mwbot(Python)

mwbot是一个基于Python的异步 Mediawiki API库,同时封装了用于PRTS wiki部分方法

快速使用

前备工作

安装

pip install mwbot -i https://pypi.org/simple/

获取Bot应有的参数

  1. 前往对应wiki的 特殊:版本 页面获取wiki的index.php, api.php的路径
  2. 前往对应wiki的 特殊:BotPasswords 创建一套机器人密码
详细过程
  1. 填入“机器人名称”。(如:BotName)

  2. 选择下方的权限

    • 这将能够限制通过机器人密码登录后的账户权限,尤其是当你的人工账户和机器人是同一账户时,这将有效保护你的账户。
    • bot只能使用您选中的与您拥有的权限的交集。
  3. 创建成功,获得机器人密码,你将有两种登录机器人的方式,任意一种都能登录至机器人账户:

    • 登录名为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


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.42.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mwbot-1.0.42-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mwbot-1.0.42.tar.gz.

File metadata

  • Download URL: mwbot-1.0.42.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.25.9 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for mwbot-1.0.42.tar.gz
Algorithm Hash digest
SHA256 9b66892cc3428991d2e3b02f00fee56b15cea960a68569c01d892413752f332b
MD5 a93eca4f5437087d00effda6cc8e66e1
BLAKE2b-256 3064cf4f72d84a643c84ae02e3cf7b7da08f9f07292bc04be47157c41c8075a7

See more details on using hashes here.

File details

Details for the file mwbot-1.0.42-py3-none-any.whl.

File metadata

  • Download URL: mwbot-1.0.42-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.25.9 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for mwbot-1.0.42-py3-none-any.whl
Algorithm Hash digest
SHA256 bbd31ca7339784d8529c73ade307f6661967eb5756638815946b8cab1ea139ec
MD5 72d0402e91173d3b9dc2c34c9e06c425
BLAKE2b-256 cc720087bb4f3dd46a9d0238050375ecfc320420ee60089b9fdf960669e00179

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page