# -*- coding: utf-8 -*-
import wikipedia
import pagegenerators
import catlib
import re
import time
deletereason=u"Destruir de BOTpolicia"
userdeletion=u'BOTpolicia'
def borradomasivo():
i=0
j=0
cat = catlib.Category(wikipedia.getSite(), 'Category:Wikipedia:Borrar (definitivo)')
gen = pagegenerators.CategorizedPageGenerator(cat)
gen = pagegenerators.PreloadingGenerator(gen, pageNumber = 100)
print "Generador iniciado."
for page in gen:
i=i+1
wikipedia.output(page.title())
#lectura del historial
lst=page.getVersionHistory()
#if userdeletion in lst[0][2]:
if len(lst)==2 and userdeletion in lst[0][2]:
print "***************** Destruir de botpoli *****************"
try:
page.delete (reason=deletereason, prompt=False)
j=j+1
except Wikipedia.NoPage:
print "Pag ya borrada"
else:
print "Plantilla de ", lst[0][2]
print "Num. borrados/total:", j, "/", i
while True:
borradomasivo()
time.sleep(60)
# parando el programa
wikipedia.stopme()