MediaWiki API的简单包装

python-mwapi的Python项目详细描述


一个非常简单和直接的mediawiki api包装器

简介

这个库为Mediawiki API提供了一个非常简单的方便包装。它是为了紧密地镜像由mw.Api

提供的接口。

功能

该库允许您调用mediawikiapi,而无需处理网络调用。它还具有身份验证支持和一些方便的方法。

非功能

这是反mwclient。它不会添加另一层供您在井documentedmediawiki api上理解,而且它永远不会:)

文档

MWApi

class MWApi
Class representing a single API Session, with a single authenticated user.

Useful Attributes:
tokens - Contains an edittoken & watchtoken (if populateTokens() has been called)
is_authenticated - Boolean indicating if the MWApi is sending authenticated requests

Methods defined here:

__init__(self, host, api_path=’/w/api.php’)
Create a MWApi instance

Arguments:
host - Host to which to connect to. Must include http:// or https:// and no trailing slash
api_path - Url to api.php on the host. Must start with /

get(self, params)
Makes an API request with the GET method

Arguments:
params - Parameters to send to the API. Varies depending on the action to be performed.

login(self, username, password)
Authenticates with the given credentials and logs in the user for the session.
All further requests sent from this MWApi object will be signed as said user.

Arguments:
username - The username of the user to be authenticated
password - The password of the user to be authenticated

Throws:
Throws an exception with (Message, Response) if Authentication fails

Note:
Passwords are sent as plaintext. This is a limitation of the Mediawiki API.
Use a https host if you want your password to be secure

populateTokens(self)
Populates the tokens attribute of the object with edittoken and watchtoken.
Requires that authentication has been performed already with login()

post(self, params)
Makes an API request with the POST method

Arguments:
params - Parameters to send to the API. Varies depending on the action to be performed.

request(self, method, params)
Makes a request to the API and returns a dictionary containing the results

Arguments:
method - GET or POST, depending on which API is being called
params - Parameters to send to the API. Varies depending on the action to be performed.

联系人

支持请求和火焰可以通过多种方式发送给我。

电子邮件:yuvipanda@gmail.com。推特:@yuvipanda.IRC:Freenode上的yuvipanda

你可以归档错误on Github

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在Java和Javascript之间共享常量   c#无法使用Gson反序列化字节[]   如果字符串是实十进制数字,则在Java中仅显示十进制数字   与Android Studio的java FireBase同步失败   web应用程序的Java Oracle数据库更改通知问题   数组中缺少整数的java嵌套循环   zos在z/os上以TOD格式(一天中的时间)转换Java时间戳   java JAXB未根据注释生成XML(JDK 1.7)   java使用Twitter4j和Geolocation查找在该地区发布推文的用户,但如何获取用户ID?   在Libgdx中实现简单运动模糊的java意外结果   java在Android数据库中插入另一个EditText值?   java标准偏差数组(我的算法错误)   java如何修复M1 Mac的Ant javascript标记?   java遍历树标记值的长度   java理解Springboot中的Cron,自动发送电子邮件   java如何将“Data.Json”文件从资产保存到内部存储器,然后将其用于读/写   java代码在编写FirstDuplicate方法时会遇到时间限制问题   java将HTML转换为PDF并将其添加到段落中   javascript css()未设置正文标记的背景属性