跳转到内容

用户:Tigerzeng/noteTA.py

维基百科,自由的百科全书
import mwclient

zh = mwclient.Site('zh.wikipedia.org')
zh.login('Tigerzeng','')

def addnoteTA(page, G1, comment):
    txt = '{{noteTA\n|G1 = '+G1+'\n}}\n'+page.text()
    page.save(txt, comment)

def main(cat, G1, comment):
    for page in cat:
        if type(page) == type(cat):
            main(page, G1, comment)
        else:
            txt = page.text()
            if edit(txt):
                addnoteTA(page, G1, comment)

def edit(txt):
    if '{{noteTA' in txt:
        return 0
    print(txt)
    key = int(input('Edit? '))
    return key

cat = zh.Pages['Category:巴布亚新几内亚']
main(cat, 'TO', '添加字词转换模板')