summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinijackson2014-10-15 10:25:01 +0200
committerMinijackson2014-10-15 10:25:01 +0200
commit12f8327134990bc30cefaef7816e52b68bd91699 (patch)
tree9c341a41e68c641108ba4d5da8e72ac7d726b9d1
parent1dde37d17ee8649b124ccbf4a2ab5962811916b5 (diff)
downloadwikistats-12f8327134990bc30cefaef7816e52b68bd91699.tar.gz
Adding WikimediaAPI class
-rw-r--r--src/downloader/wikimedia.py29
1 files changed, 29 insertions, 0 deletions
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 @@
1"""
2Module used to generate wikimedia API urls for several uses
3"""
4
5
6class WikimediaAPI():
7 """
8 Class used to generate wikimedia API urls for several uses
9
10 The endpoint for this project should be "http://en.wikipedia.org/w/api.php"
11 but can be other wiki api endpoint made with the Wikimedia software.
12 The return_format can be one of json, php, wddx, xml, yaml, raw, txt, dbg,
13 dump or none.
14 """
15 def __init__(self, endpoint, return_format):
16 self.endpoint = endpoint
17 self.return_format = return_format
18
19 def get_recent_changes(self, namespace="(Main)"):
20 """
21 Get the url corresponding to the latest changes made to the wiki.
22 (https://www.mediawiki.org/wiki/API:Recentchanges)
23
24 The namespace is used to restrict the results to a certain level. It
25 can be "(Main)" which is the default one, "Wikipedia", "File" or
26 others. See https://meta.wikimedia.org/wiki/Help:Namespace
27 """
28 return self.base_url + "?action=query&list=recentchanges&format="\
29 + self.return_format + "&namespace=" + namespace