Utente:BimBot/Scripts: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m ops... |
adesso dovrebbe andare |
||
Riga 21:
ic = inputchoice()
if ic == u'.':
if ic == u'P':
name = wikipedia.input(u'Inserisci il nome della pagina da cui ricavare i redirect [punto per terminare]:')
if name == u'.':
page = wikipedia.Page(wikipedia.getSite(), name)
redirectLinks = getlinkstoredirectstopage(page)
Riga 31:
name = wikipedia.input(u'Inserisci il nome del redirect [punto per terminare]:')
if name == u'.':
page = wikipedia.Page(wikipedia.getSite(), name)
redirectLinks[page.title()] = page.getReferences()
for i in redirectLinks:
print i▼
page = wikipedia.Page(wikipedia.getSite(), i)
dest = wikipedia.Page(wikipedia.getSite(), page.getRedirectTarget())
ref = redirectLinks[i]
for j in ref:
oldtext = j.get()
print j▼
lnks = sgamalink(i, oldtext)
for k in lnks:
print "Nome del redirect: " + page.aslink()
print "Pagina a cui punta il redirect: " + dest.aslink()
print "Link in via di correzione: " + k
print "Pagina che contiene il link: " + j.aslink()
if u'|' in k:
regex = u"\[\[%s\|(.*?)\]\]" % i
p = re.compile(regex, re.IGNORECASE)
choice =
else:
choice = linkchoice(dest.title(), i)
if choice == u'.':
newtext = sistema(oldtext, page.title(), choice)
wikipedia.showDiff(oldtext, newtext)
choice = wikipedia.inputChoice(
if choice in ['Y', 'y']:
wikipedia.setAction(u'Correggo i link che puntano al redirect "%s"' % page.title())
j.put(newtext)
wikipedia.stopme();
def safeexit():
wikipedia.stopme()
exit()
def getlinkstoredirectstopage(page):
Line 96 ⟶ 104:
def sgamalink(oldtitle, oldtext):
regex = u"\[\[%s
p = re.compile(regex, re.IGNORECASE)
lst = re.findall(p, oldtext)
Line 104 ⟶ 112:
regex = u"\[\[%s.*?\]\]" % oldtitle
p = re.compile(regex, re.IGNORECASE)
text = re.sub(p,
return text
Line 110 ⟶ 118:
if __name__==u"__main__":
main()
</pre>
|