Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Python:French commune.py
#!/usr/bin/python # -*- coding: utf-8 -*- """ Program for Dario. """ # # (C) Filnik, 2007-2008 # # Distributed under the terms of the MIT license. # __version__ = '$Id: $' # import re import wikipedia, catlib site = wikipedia.getSite('simple', 'wikipedia') category = u'Category:Communes_in_Calvados' generator = catlib.categoryAllPageObjectsAPI(category, site = site) def main(): enwiki = wikipedia.getSite('en', 'wikipedia') for page in generator: wikipedia.output(u'Loading %s...' % page.title()) try: simplePageText = page.get() except wikipedia.NoPage: wikipedia.output(u'%s seems to have been deleted.. strange' % page.title()) continue regex = re.compile(r'\{\{(?:[Tt]emplate:|)(?:Infobox |)[Ff]rench[ _]commune\s*?\|(.*?)\}\}', re.DOTALL) checking = regex.findall(simplePageText) if checking != []: wikipedia.output(u'Template French commune already on %s, skipping..' % page.title()) continue enpage = wikipedia.Page(enwiki, page.title()) try: enPageText = enpage.get() except wikipedia.NoPage(): wikipedia.output(u"%s doesn't exist on en.wiki" % page.title()) continue template_raw = regex.findall(enPageText) if template_raw == []: wikipedia.output(u'Template not found in the en.wiki page, skip %s' % page.title()) continue template = "{{French commune\n|%s}}" % template_raw[0] page.put("%s\n%s" % (template, simplePageText), comment = "Bot: Adding French commune template, taken from en.wiki") if __name__ == "__main__": try: main() finally: wikipedia.stopme()