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

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

问题描述

嗨我有一个 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 更新媒体维基文章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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