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 FirebaseInstanceId。getInstance()始终为空   linux Java执行文件错误   javaspringboot:如何使用Ajax在springboot和Thymeleaf中创建进度条?   java禁用在安卓上使用传单时启用setJavaScriptEnabled   java如何在主体中发布原始类型JSON数据?   消除JAVA While循环中的额外输出   如何在java中直接将基本数据类型分配给自定义类   java为什么addNode()方法返回编译错误“类型中的方法…不适用于参数…”,我该如何修复它?   java惰性合成可观察对象   eclipse Java Blackberry位图单击   java Android:AsyncTask对象[]无法在doInBackground中强制转换   java有没有办法重构或改进这段代码?   java如何使用系统以十六进制打印字节。出来普林顿?   多线程如何在我的java聊天室中调试“java.net.UnknownHostException”?   java如何从Google App Engine下载应用程序源文件   java如何在Spring Data Mongo的聚合$group中使用类似$dateToString   java IBM websphere application server未在MyEclipse8中启动。0