使用者:Qnm/task/1/1.py

import mwclient as mwc
import wikitextparser as wtp
import time, re
zh = mwc.Site('zh.wiktionary.org', clients_useragent = UA)
en = mwc.Site('en.wiktionary.org', clients_useragent = UA)
pnl = ['峠','一','鉛','飮','猾','獪','芬','洪','誠','夕','詠','因','妙','孖','寮','昔','櫛','濆','箸','車','頬','掮','串','你','係','入','内','卌','只','帳','庵','忍','達','金','阮']
n = len(pnl)
zh.login(UN, PWD)
en.login(UN, PWD)
zpgl = list(map(lambda pn: zh.Pages[pn], pnl))
epgl = list(map(lambda pg: en.Pages[dict(pg.langlinks())['en']], zpgl))
fail = []
for i in range(n):
    def g(t): return re.fullmatch(r'[jJ]a-readings\s*', t.name)
    zpg = zpgl[i]
    epg = epgl[i]
    zast = wtp.parse(zpg.text())
    east = wtp.parse(epg.text())
    zts = list(filter(g, zast.templates))
    ets = list(filter(g, east.templates))
    #if len(zts) != 1 or len(ets) != 1:
    if i == 10 or i == 19 or i == 22:
        fail.append(i)
        continue
    zt = zts[0]
    et = ets[0]
    zpg.edit(zast.string.replace(zt.string, et.string), '见[[User:Qnm/task/1]],半自动搬运en的日语汉字读音')
    time.sleep(1)