import pywikibot
site = pywikibot.Site('ml', 'wikipedia') # Malayalam Wikipedia
site.login()
# Read page titles from replace.txt
with open('replace.txt', 'r', encoding='utf-8') as file:
page_titles = file.read().splitlines()
# Search and replace for each page title
search_term = 'അള്ളാഹു'
replace_term = 'അല്ലാഹു'
for title in page_titles:
page = pywikibot.Page(site, title)
page_text = page.text
# Check if the page text already contains the replacement term
if replace_term not in page_text:
updated_text = page_text.replace(search_term, replace_term)
# Edit the page with the updated text
page.text = updated_text
page.save(summary='Fixing misspelling')
else:
print(f'Skipping page {title} as it already contains the replacement term.')
0 comments:
Post a Comment