-
-
Save iilxy/78125a3a5bef33d37917ee541067a4e3 to your computer and use it in GitHub Desktop.
Download image files from Chrome's Developer tools "Save All as HAR".
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
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