-
-
Save jdorrance/5800897 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
getPage("/content/acs1/en/pressroom/presspacs/2013/acs-presspac-march-20-2013").recurse{ p-> | |
p.node.recurse{ n -> | |
def txtNode = n.get("text") | |
if(txtNode?.contains(p.name)){ | |
def xml = new XmlSlurper().parseText(txtNode)?.childNodes()?.each(){ | |
if(it.name =="img"){ | |
def src = it.attributes().get("src") | |
println 'Page NAME : ' + p.name | |
println ' IMG TAG SRC : ' + src | |
println ' PARENT name ' + p.node.parent.name | |
def oldPath = "presspacs/" + p.name | |
def newPath = "presspacs/" + p.node.parent.name + "/" + p.name | |
println ' REPLACING.... : ' + oldPath +" with " + newPath | |
def repTxtNode = txtNode.replace(oldPath,newPath) | |
n.set("text",repTxtNode) | |
} | |
} | |
} | |
println 'SAVING SESSION' | |
session.save() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment