使用Python更新媒体Wiki文章? [英] Updating a media wiki article using Python?

查看:90
本文介绍了使用Python更新媒体Wiki文章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一份Cron工作,该工作收集有关服务的一些统计信息.我需要cron作业以编程方式更新媒体Wiki页面(附加到页面). 我正在使用python作为cron,所以我最好的选择是什么,是否有任何mediawiki/python库的示例,或者Media wiki是否公开了我可以使用的任何HTTP/REST API(可能是通过扩展名).

Hi I have a cron job which collects some statistics about a service. I need the cron job to update a media wiki page (append to the page) programmatically. I am using python for the cron so what are my best options, are there any examples of mediawiki/python libraries or does Media wiki expose any HTTP/REST apis which I can use (may be through an extension).

谢谢

推荐答案

如果PyWikipediaBot太重,请尝试使用Python模块 mwclient .

If PyWikipediaBot is too heavy, try the Python module mwclient.

您可以登录,查看页面的当前内容,进行更改,然后在少于10行的时间内查看它.(示例) .

You can login, view a page’s current content, make your change and then view it in less than 10 lines (example).

import mwclient
site = mwclient.Site('en.wikipedia.org')
site.login('Pfctdayelise','password')
page = site.Pages['User:Pfctdayelise/Test']
text = page.edit()
print text.encode('utf-8')
newtext = "\n\nTesting the write api without logging in.\n"
page.save(text+newtext,summary='testing write api')

这篇关于使用Python更新媒体Wiki文章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆