Created
May 11, 2014 16:11
-
-
Save anonymous/f451cdbddcb864283817 to your computer and use it in GitHub Desktop.
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
// este código está no domínio público | |
import net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot | |
import net.sourceforge.jwbf.core.contentRep.Article | |
// falsos positivos | |
def visitados = [:] | |
visitados["PAGENAME"] = true | |
visitados["!"] = true | |
visitados[""] = true | |
MediaWikiBot wikiBot =j new MediaWikiBot("http://pt.wikipedia.org/w/"); | |
def predef = [["Predefinição:Info/Município_do_Brasil", "digitado manualmente"]] | |
def a | |
Article article | |
while(!predef.empty) { | |
def x = predef[-1][1] | |
a = predef.pop()[0] | |
if(!visitados[a]) { | |
article = wikiBot.getArticle(a); | |
visitados[a] = true | |
println ((a -"Predefinição:") + " vindo de '$x'" | |
+ (article.empty ? "..não existe ou estava vazio": "") | |
) | |
def title = article.title.replaceAll('/', '!') // o caractere '/' não é permitido como nome de arquivo | |
//new File("/home/usuario/Documentos/Wiki/$title").write(article.text) | |
predef.addAll( | |
((article.text =~ /[^{]\{\{([^{#}!|]+)/ ). | |
collect{ "Predefinição:" + it[1].trim() }. | |
unique()).collect{[it, a]} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment