Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f451cdbddcb864283817 to your computer and use it in GitHub Desktop.
Save anonymous/f451cdbddcb864283817 to your computer and use it in GitHub Desktop.
// 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