From 12f8327134990bc30cefaef7816e52b68bd91699 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 15 Oct 2014 10:25:01 +0200 Subject: Adding WikimediaAPI class --- src/downloader/wikimedia.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/downloader/wikimedia.py diff --git a/src/downloader/wikimedia.py b/src/downloader/wikimedia.py new file mode 100644 index 0000000..1905d0a --- /dev/null +++ b/src/downloader/wikimedia.py @@ -0,0 +1,29 @@ +""" +Module used to generate wikimedia API urls for several uses +""" + + +class WikimediaAPI(): + """ + Class used to generate wikimedia API urls for several uses + + The endpoint for this project should be "http://en.wikipedia.org/w/api.php" + but can be other wiki api endpoint made with the Wikimedia software. + The return_format can be one of json, php, wddx, xml, yaml, raw, txt, dbg, + dump or none. + """ + def __init__(self, endpoint, return_format): + self.endpoint = endpoint + self.return_format = return_format + + def get_recent_changes(self, namespace="(Main)"): + """ + Get the url corresponding to the latest changes made to the wiki. + (https://www.mediawiki.org/wiki/API:Recentchanges) + + The namespace is used to restrict the results to a certain level. It + can be "(Main)" which is the default one, "Wikipedia", "File" or + others. See https://meta.wikimedia.org/wiki/Help:Namespace + """ + return self.base_url + "?action=query&list=recentchanges&format="\ + + self.return_format + "&namespace=" + namespace -- cgit v1.2.3