]> code.communitydata.science - rises_declines_wikia_code.git/blob - mediawiki_dump_tools/Mediawiki-Utilities/examples/lib.persistence.api.py
add copy of the GPL
[rises_declines_wikia_code.git] / mediawiki_dump_tools / Mediawiki-Utilities / examples / lib.persistence.api.py
1 import pprint
2 import re
3
4 from mw.api import Session
5 from mw.lib import persistence
6
7 session = Session("https://en.wikipedia.org/w/api.php")
8
9 rev, tokens_added, future_revs = persistence.api.score(session, 560561013,
10                                                        properties={'user'})
11
12 words_re = re.compile("\w+", re.UNICODE)
13
14 print("Words added")
15 for token in tokens_added:
16     if words_re.search(token.text):
17         print("'{0}' survived:".format(token.text))
18         for frev in token.revisions:
19             print("\t{revid} by {user}".format(**frev))

Community Data Science Collective || Want to submit a patch?