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:TemplateFromXLS.py
#!/usr/bin/python # -*- coding: iso-8859-1 -*- # # (C) Filnik and Tomsen, 2008 # # Distributed under the terms of the MIT license. # from xlrd import * import re, wikipedia def main(): xls_file = 'tomsen-neu.xls' wb = open_workbook(xls_file) sh = wb.sheet_by_index(0) site = wikipedia.getSite() text = \ u"""{{Wikiaprojekt |Projekttitel = __project_name__ |Logo = __logo__ |Wikiname = __link__ |Status = |Startdatum = __data__ |GrĂ¼nder = __grunder__ |Adoptiert = |WikiIndex = |Klicklink = __Klicklink__ }} __descripton__ [[Kategorie:Zu kategorisieren]] [[en:__language__]] """ for rownum in range(sh.nrows): listData = sh.row_values(rownum) #print "Project: %s" % listData[0] #print "Link: %s" % listData[1] #print 'Data: %s' % listData[2] #print 'Grunder: %s' % listData[3] text_to_insert = text if type(listData[0]) != type('') and str(type(listData[0])) != "<type 'unicode'>": project_name = str(listData[0]) else: project_name = listData[0] page = wikipedia.Page(site, project_name) if page.exists(): wikipedia.output(u'%s already exists, skip.' % project_name) continue wikipedia.output(u'Loading %s...' % project_name) data = str(listData[2]).replace(',', '.') if type(listData[3]) != type('') and str(type(listData[3])) != "<type 'unicode'>": grunder = str(listData[3]) else: grunder = listData[3] link = re.sub(r'http://(w\.w\.w\.|)', r'', re.sub(r'\.wikia.com', '', listData[1])) text_to_insert = re.sub(r'__project_name__', project_name, text_to_insert) text_to_insert = re.sub(r'__link__', link, text_to_insert) text_to_insert = re.sub(r'__data__', data, text_to_insert) text_to_insert = re.sub(r'__grunder__', grunder, text_to_insert) Klicklink = 'das ' + project_name + ' Wikia' text_to_insert = re.sub(r'__Klicklink__', Klicklink, text_to_insert) if 'de.' in link: url = re.sub(r'de\.','', link) logo = 'http://images.wikia.com/' + url + '/de/images/b/bc/Wiki.png' else: logo = 'http://images.wikia.com/' + link + '/images/b/bc/Wiki.png' text_to_insert = re.sub(r'__logo__', logo, text_to_insert) language = wikipedia.input(u'Link to the English Central:') text_to_insert = re.sub(r'__language__', language, text_to_insert) descripton = wikipedia.input(u'Descripton:') text_to_insert = re.sub(r'__descripton__', descripton, text_to_insert) wikipedia.output(u'This is the result:\n') wikipedia.output(text_to_insert) choose = wikipedia.input(u'Should I post this? [y]es, [n]o') while 1: if choose.lower() in ['yes', 'y', 'ja', 'j']: page.put(text_to_insert, "[[User:Tomsen|Tomsen]]: Wiki-Import") break elif choose.lower() in ['no', 'n', 'nein']: break else: choose = wikipedia.input(u'Wrong input, retry please. yes or no?') continue if __name__ == "__main__": try: main() finally: wikipedia.stopme()