User:Ritchie333/dyks.py
Appearance
# A pywikibot script to dump out all DYK nominations in a list
import re
import pywikibot
from pywikibot import pagegenerators
import sys
username = sys.argv[ 1 ]
reDYK = re.compile( '^Giving DYK credit for \[\[([^\]]+)\]\]' )
site = pywikibot.Site()
tp = pywikibot.Page( site, 'User talk:' + username )
for rev in tp.revisions(reverse=True):
if rev.user == 'DYKUpdateBot':
match = reDYK.match( rev.comment )
if match is not None:
page = match.group( 1 )
print( '# ' + rev.timestamp.strftime( '%d %B %Y' ) + ' [[' + page + ']]' )