Created
October 24, 2011 18:15
-
-
Save vssun/1309693 to your computer and use it in GitHub Desktop.
Find and Replace on Subpages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
അനേകം ഉപതാളുകളിലെ ഉള്ളടക്കത്തിൽ കണ്ടെത്തി മാറ്റാൻ | |
നിർമ്മിച്ചത്: സുനിൽ വി.എസ്. | |
തിയതി: 2011-10-24 | |
മാറ്റങ്ങൾ | |
======= | |
1. ഉള്ളടക്കത്തിൽ നേരത്തേ മാറ്റം വന്നിട്ടുണ്ടെങ്കിൽ (മാറ്റം വരുത്തേണ്ട ഭാഗം താളിൽ നേരത്തേയുണ്ടെങ്കിൽ) പ്രവർത്തിക്കാതിരിക്കാനുള്ള കോഡ് കൂട്ടിച്ചേർത്തു. | |
""" | |
import wikipedia | |
import pagegenerators | |
#പ്രധാന പ്രോഗ്രാം ഇവിടെ തുടങ്ങുന്നു. | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു താഴെ വരുത്തുക | |
siteFamily = 'wikisource' | |
siteLangCode = 'ml' | |
workingPage = ur'നാരായണീയം/' #ഏതു താളിൽ പണിചെയ്യണം? പ്രധാന താൾ കൂടി ഉൾപ്പെടുത്തണമെങ്കിൽ അവസാനമുള്ള / ഒഴിവാക്കുക | |
findTextPage = 'user:VsBot/Find' #കണ്ടെത്താനുള്ള ഉള്ളടക്കം എവിടെ നിന്നെടുക്കണം? | |
replaceTextPage = 'user:VsBot/Replace' #എന്തുവച്ച് മാറ്റണം? | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു മുകളിൽ വരുത്തുക | |
wikiSite = wikipedia.Site(code=siteLangCode, fam=siteFamily) | |
myFindText=wikipedia.Page(site=wikiSite,title=findTextPage).get() | |
myReplaceText=wikipedia.Page(site=wikiSite,title=replaceTextPage).get() | |
for myPage in pagegenerators.PrefixingPageGenerator(workingPage): | |
wikipedia.output("Working on " + myPage.title()) | |
if myPage.get().count(myReplaceText)<=0: #ടെക്സ്റ്റ് നേരത്തേതന്നെ ഉള്ളടക്കത്തിലില്ലെങ്കിൽ മാത്രം പ്രവർത്തിക്കുക | |
myPage.put(myPage.get().replace(myFindText,myReplaceText),comment=ur'യന്ത്രം: വാചകങ്ങൾ കണ്ടെത്തി മാറ്റം വരുത്തുന്നു') | |
else: | |
wikipedia.output("This page had already been updated") | |
wikipedia.stopme() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment