網頁

2011年8月8日星期一

Python-wikitools

MediaWiki provides a good API for us to access to the data contained in the MediaWiki database. The MediaWiki API is based on HTTP calls. Python-wikitools is python scripts and modules to interact with the MediaWiki API. I think it is very easy to use.

Python-wikitools: http://code.google.com/p/python-wikitools/

There are three modules that I often use, i.e. wiki, page and api. In the beginning of python script, it is required to import these three modules.

from wikitools import wiki
from wikitools import page
from wikitools import api

To access the MediaWiki, we need to create Wiki object.
myWiki = wiki.Wiki('http://my.wikisite.org/w/api.php')

If I want to get a page information, I can create a WIKI page object. Then, I can get the information by the method, "getWikiText()".
wikiPage = page.Page(myWiki, title)
wikiText = wikiPage.getWikiText()


Limitations:
Can only do what MediaWiki API can do.

沒有留言:

發佈留言