blob: 1905d0aac8d236aa71000153914c31dfd9452a13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
|