-
-
Save burakbengi/05590ff2edc0b9a4a48b641e783c3488 to your computer and use it in GitHub Desktop.
Rough script to extract images from HTTP Archive (HAR) files
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
const fs = require('fs'); | |
const file = JSON.parse(fs.readFileSync('./dump.har')).log; | |
const targetMimeType = 'image/jpeg'; | |
let count = 1; | |
for (const entry of file.entries) { | |
if (entry.response.content.mimeType === targetMimeType) { | |
// ensure output directory exists before running! | |
fs.writeFileSync(`output/${count}.png`, new Buffer(entry.response.content.text, 'base64'), 'binary'); | |
count++; | |
} | |
} | |
console.log(`Grabbed ${count} files`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment