import pywikibot
lang_code = 'zh-min-nan'
project = 'wikipedia'
category = 'XXXXX'
site = pywikibot.Site(lang_code, project)
cat = pywikibot.Category(site, category)
listOfArticles = list(set(cat.articles(recurse=False)))
page_list = []
for i in range(len(listOfArticles)):
page_list.append(listOfArticles[i].title())
# Ēng chit-ê tāi-bé ē-sái lia̍h "Lūi-pia̍t:XXXXX" lāi-té ê só͘-ū bûn-chiuⁿ.
import pywikibot
lang_code = 'zh-min-nan'
project = 'wikipedia'
page_title = ['XXXXX', 'YYYYY', 'ZZZZZ']
category_orig = 'AAAAA'
category_new = 'BBBBB'
site = pywikibot.Site(lang_code , project)
for i in range(len(page_title)):
page = pywikibot.Page(site, page_title)
if "[[Category:{0}".format(category_orig) in page.text:
page.text = page.text.replace("[[Category:{0}".format(category_orig), "[[Category:{0}".format(category_new))
elif "[[Lūi-pia̍t:{0}".format(category_orig) in page.text:
page.text = page.text.replace("[[Lūi-pia̍t:{0}".format(category_orig), "[[Lūi-pia̍t:{0}".format(category_new))
else:
continue
page.save("lūi-pia̍t thè-ōaⁿ")
# Ēng chit-ê tāi-bé ē-sái kā chē-chē bûn-chiuⁿ ("XXXXX", "YYYYY", "ZZZZZ") ùi "Lūi-pia̍t:AAAAA" sóa khì tī "Lūi-pia̍t:BBBBB".
import pywikibot
lang_code = 'zh-min-nan'
project = 'wikipedia'
category = 'XXXXX'
site = pywikibot.Site(lang_code, project)
cat = pywikibot.Category(site, category)
listOfArticles = list(set(cat.articles(recurse=False)))
for i in range(len(setOfArticles)):
page = pywikibot.Page(site, listOfArticles[i])
if "[[Category:{0}]]".format(category) in page.text:
page.text = page.text.replace("[[Category:{0}]]".format(category), "")
elif "[[Lūi-pia̍t:{0}]]".format(category) in page.text:
page.text = page.text.replace("[[Lūi-pia̍t:{0}]]".format(category), "")
else:
continue
page.save("lūi-pia̍t î-tû")
# Ēng chit-ê tāi-bé ē-sái kā "Lūi-pia̍t:XXXXX" lāi ê só͘-ū bûn-chiuⁿ î-tû.