Skip to content

Instantly share code, notes, and snippets.

@iilxy
Forked from tango238/getimage.groovy
Created June 5, 2017 07:33
Show Gist options
  • Save iilxy/78125a3a5bef33d37917ee541067a4e3 to your computer and use it in GitHub Desktop.
Save iilxy/78125a3a5bef33d37917ee541067a4e3 to your computer and use it in GitHub Desktop.
Download image files from Chrome's Developer tools "Save All as HAR".
import groovy.json.*
def slurper = new JsonSlurper()
def text = new File('hoge.com.har').text
def root = slurper.parseText(text)
def getImage(address){
def command = 'wget ' + address
def proc = command.execute()
proc.waitFor()
}
def entries = root.log.entries
entries.each {
def orgurl = it.request.url
def url = orgurl.toLowerCase()
if(url.endsWith('jpg') || url.endsWith('jpeg') || url.endsWith('png')){
try{
getImage(orgurl)
}catch(Exception e){
println e
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment