import pywikibot import re from pywikibot import pagegenerators site = pywikibot.Site() page = pywikibot.Page(site, u"User:PearBOT/test") text = page.text templates=pywikibot.textlib.extract_templates_and_params(text) def extractParameterValue(parmeter_name): regex = parameter_name + "=" for x in templates: if re.search(x): return re.replace(regex,,x) text += extractParameterValue(length main) page.text = text page.save(u"Bot test")