Skip to content

Instantly share code, notes, and snippets.

@cosmin
Created April 26, 2011 11:55
Show Gist options
  • Save cosmin/942142 to your computer and use it in GitHub Desktop.
Save cosmin/942142 to your computer and use it in GitHub Desktop.
Extract images, css and js from a HAR archive
#!/usr/bin/env python
import sys
import json
def process(filename):
inp = open(filename, 'r')
data = json.load(inp)
inp.close()
entries = [x['request']['url'] for x in data['log']['entries']]
csses = [el for el in entries if el.endswith('css')]
images = [el for el in entries if el.endswith('png') or el.endswith('gif')]
for image in images:
print "I", image
print ""
for css in csses:
print "C", css
if __name__ == "__main__":
process(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment