I'm trying to find the textual differences between two revisions of a given Wikipedia page using mwclient. I have the following code:
import mwclient
import difflib
site = mwclient.Site('en.wikipedia.org')
page = site.pages['Bowdoin College']
texts = [rev for rev in page.revisions(prop='content')]
if not (texts[-1][u'*'] == texts[0][u'*']):
##show me the differences between the pages
Thank you!
It's not clear weather you want a
difflib-generated diff or a mediawiki-generated diff usingmwclient.In the first case, you have two strings (the text of two revisions) and you want to get the diff using difflib:
(difflib can also generate an HTML diff, refer to the documentation for more info.)
But if you want the MediaWiki-generated HTML diff using
mwclientyou'll need revisionids:Then use the compare action to compare the revision ids: