# -*- coding: utf_8 -*- import sys sys.path.append('./core') import pywikibot import traceback import os article_name = 'List of Wikipedias by sample of articles' meta_wiki = pywikibot.Site('meta', 'meta') meta_page = pywikibot.Page(meta_wiki, article_name) article = meta_page.get(get_redirect=False) f = open('PreviousScores.txt', 'w') count = 0 lang_last = 0 lang_first = article.find(u'[[:', lang_last) while lang_first > -1: lang_last = article.find(u'|', lang_first) lang = article[lang_first+3:lang_last-1] score_first = article.find(u'style = "background:',lang_last) score_last = article.find(u'|', score_first+32) score = article[score_first+31:score_last-1] f.write(lang + ' ' + score + '\n') count += 1 print count, lang, score lang_first = article.find(u'[[:', score_last) f.close()