使用者:P-bot/redirect repair.py
外觀
# -*- coding: utf-8 -*-
import wikipedia, pagegenerators
def main():
gen = None
text = None
genFactory = pagegenerators.GeneratorFactory()
for arg in wikipedia.handleArgs():
generator = genFactory.handleArg(arg)
if generator:
gen = generator
summary = u'机器人:修复简繁重定向条目统计错误'
temptitle='User:P-bot/temp4'
preloadingGen = pagegenerators.PreloadingGenerator(gen)
for page in preloadingGen:
try:
text = page.get(get_redirect=True)
page.move(temptitle,summary,deleteAndMove=True,fixredirects=False)
newpage = wikipedia.Page(wikipedia.getSite(), page.title())
newpage.put(newtext=text,comment=summary)
except wikipedia.NoPage:
wikipedia.output(u'页面不存在')
if __name__ == '__main__':
try:
main()
finally:
wikipedia.stopme()