Dump Browser HAR Content
Extract response content from HAR files, which can be captured by browser developer tools.
For debugging purposes, browsers can typically export *.har
files that capture all responses from their “developer tools”
(HTTP Archive, W3C).
In Firefox, HAR files can be obtained by Save all as har, Chrome provides Save as HAR with Content.
Also, these archives can be used for circumventing file download restrictions, in case of loading mechanisms that require a “real” browser environment or a particular session.
As HAR files are simply made of request/response JSON, they can be trivially parsed with Python. A small script is enough to extract response content for certain URLs and dump the results to corresponding files:
usage: har_dump.py [-h] [--url URL] archive.har
Extract responses from a HAR file, which can be exported by browser dev tools.
Files are written for URLs that match a certain regular expression.
positional arguments:
archive.har http archive file to process
optional arguments:
-h, --help show this help message and exit
--url URL regular expression for the request url, no response content dump otherwise