Skip to content

Instantly share code, notes, and snippets.

@jdorrance
Forked from anonymous/gist:5800488
Created June 17, 2013 22:02
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 jdorrance/5800897 to your computer and use it in GitHub Desktop.
Save jdorrance/5800897 to your computer and use it in GitHub Desktop.
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