Skip to content

Instantly share code, notes, and snippets.

@baldrailers
Forked from amishshah/har-extract.js
Created March 2, 2022 00:40
Show Gist options
  • Save baldrailers/878ab7a3f5f525257dee1b47ab626a3c to your computer and use it in GitHub Desktop.
Save baldrailers/878ab7a3f5f525257dee1b47ab626a3c to your computer and use it in GitHub Desktop.
Rough script to extract images from HTTP Archive (HAR) files
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