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理解泛型   java Guava:如何自定义减少多重映射?   java无法构建实体管理器工厂JPA/Hibernate   不区分大小写的LDAP搜索   在java中同时调用所有类对象中的方法   java做高级数字计算?2.1k等于2100等。。?   java Camel netty组件:未能创建选择器   exceljava。lang.ClassCastException:ExcelStreamAction无法强制转换为com。开放交响乐团。xwork2。行动   java避免对嵌套a4j:区域进行验证   java如何使一帧在1秒内显示50次,每次显示时消失   java一个HashMap的遍历,我得到NullPointerException   windows HP Stream 8平板电脑。。。Java swing JScrollPane滚动在触摸屏上不工作   java如何在运行时根据用户/程序员的需要自动增加数组的大小?