Given a Wikipedia user/editor id and a timeframe, is there a way in Python to get details about all the contributions/edits made the user/editor? I want to fetch details like page edited, action taken, bytes added/deleted in case of revision, and comments (if any). Is this possible at all?
Many thanks!
Yes, pywikibot
’s User
class has a .contributions()
method you can use to iterate over all contributions for a user.
It returns a generator that, for each edit, yields a tuple of (pywikibot.Page, oldid, pywikibot.Timestamp, comment)
. You don’t get the diff, but you can retrieve the page at this point (page.getOldVersion(oldid=…)
) and do the diff from the point just before.
Simple code example:
from pywikibot import Site, User
user = User(Site(), "SanMelkote")
for page, oldid, ts, comment in user.contributions():
print(Page.title(), comment)