使用者:CrowleyBot/task/11

zcat dewiktionary-20210720-all-titles.gz | grep -e "^10\sRef-" > /tmp/tmpd
zcat enwiktionary-20210720-all-titles.gz | grep -e "^10\sR:" > /tmp/tmpe
cat /tmp/tmpd | awk '!/[/]Doku$/{print substr($0, 8) "~de"}' | sort > /tmp/tmpd1
cat /tmp/tmpe | awk '!/[/]documentation$/{print substr($0, 6) "~en"}' | sort > /tmp/tmpe1
cat /tmp/tmpd1 > /tmp/tmpf
cat /tmp/tmpe1 >> /tmp/tmpf
在vim中
:sort
:%s/^\(.*\)\~de\n\1\~en/@\1/g
:%s/^[^@].*\n//g
:%s/@//g
在python中
def process1():
    dp = 'Template:Ref-' + pn[i]
    ep = 'Template:R:' + pn[i]
    dpg = de.Pages[dp].resolve_redirect()
    epg = en.Pages[ep].resolve_redirect()
    dtxt = dpg.text()
    etxt = epg.text()
    print((i, pn[i]))
    print(dtxt)
    print()
    print(etxt)

def process2():
    dp = 'Template:Ref-' + pn[i]
    ep = 'Template:R:' + pn[i]
    try:
        wd.post('wblinktitles', fromsite='dewiktionary', fromtitle=dp, tosite='enwiktionary', totitle=ep, token=wd.get_token('edit', True), bot=1, summary='link de en wikt') # 这个API并不支持summary
    except mwc.errors.APIError as e:
        print((i, pn[i], e))