Usuário:Rei-artur/python/contador wiki.py
< Usuário:Rei-artur | python
Criado por Lameiro.
# -*- coding: utf-8 -*- import wikipedia import urllib from urllib import urlopen class FirefoxFaker(urllib.URLopener): version = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b1) Gecko/20060601 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 (Ubuntu-edgy)" #User-Agent string do meu browser/OS def __init__(self, *args): urllib.URLopener.__init__(self) urllib._urlopener = FirefoxFaker() langs = ('en', 'de', 'fr', 'pl', 'ja', 'nl', 'it', 'sv', 'pt', 'es') nowdict = {} for lang in langs: site = 'http://%s.wiki.x.io/wiki/Special:Statistics?action=raw' % lang getSite = urlopen(site).read() for stat in getSite.split(';'): if 'good' in stat: nowdict[lang] = stat[5:] wpSave = (u"""<timeline> TimeAxis = orientation:horizontal format:yyyy ImageSize = width:300 height:auto barincrement:17 Period = from:0 till:1500000 PlotArea = left:25 bottom:15 top:10 right:10 AlignBars = justify Colors = id:lightline value:rgb(0.6,0.6,0.6) id:actual value:rgb(0.6,0.6,1) id:anterior value:rgb(0.6,1,1) ScaleMinor = increment:100000 gridcolor:lightline start:0 LineData = at:1000000 color:Green layer:back at:500000 color:Green layer:back PlotData= bar:en mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:de mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:fr mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:pl mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:ja mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:nl mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:it mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:sv mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) bar:pt mark:(line,black) width:12 from:0 till:%s color:Red text:%s shift:(25,-4) bar:es mark:(line,black) width:12 from:0 till:%s color:actual text:%s shift:(25,-4) </timeline> <small>'''''última actualização:''' {{subst:CURRENTDAY}} de {{subst:CURRENTMONTHNAME}}''</small> """) % (nowdict['en'], nowdict['en'], nowdict['de'], nowdict['de'], nowdict['fr'], nowdict['fr'], nowdict['pl'], nowdict['pl'], nowdict['ja'], nowdict['ja'], nowdict['nl'], nowdict['nl'], nowdict['it'], nowdict['it'], nowdict['sv'], nowdict['sv'], nowdict['pt'], nowdict['pt'], nowdict['es'], nowdict['es'], ) print wpSave comment = {'pt':u'Atualizando contador de edições de bots'} pageTitle = u'Usuário:Rei-artur/testes/6' title = wikipedia.Page(wikipedia.getSite(), pageTitle) msg = wikipedia.translate(wikipedia.getSite(), comment) title.put(wpSave, msg)