Extract HTML Files from HAR
Web browsing sessions can be saved as HAR files for debugging. "Save as HAR" is supported by Firefox, Chrome, OWASP ZAP and Burp.
This tool extracts HTML web pages from HAR file.
Install
Har-extract-text.py is free software under GNU General Public License, version 3.
$ wget https://terokarvinen.com/2023/extract-har-files/har-extract-text.py
$ chmod u+x har-extract-text.py
And enjoy
$ ./har-extract-text.py -i tero.har
Saving a HAR file
Web browsers and MITM proxies can save HAR files. HAR files are supported by Firefox, Chrome, Edge, OWASP ZAP and Burp.
Firefox: F12: Network (tab). Right click: "Save all as HAR".
OWASP ZAP: History (pane). Select multiple URLs. Right click: "Save Selected Entries as HAR (HTTP Archive File)"
Usage
Save your HAR file. Here, I've saved it as "tero.har".
$ har-extract-text.py -i tero.har
Created output directory "har-out/."
Loaded HAR file "tero.har" with 25 entries.
Wrote "har-out/Foo.html": 23 567 chars.
Wrote "har-out/Bar.html": 42 000 chars.
...
Wrote 25 HTML files to "har-out/". Done.
Now you can open the HTML files using a web browser.
Help
$ ./har-extract-text.py --help
usage: har-extract-text.py [-h] [-v] [-d] [-m MATCH] [-i INFILE] [-o OUTDIR] [-f]
Extract text (e.g. HTML pages) from HAR file
First, save a HAR file using OWASP ZAP (tested) or Firefox. Then
har-extract-text.py tero.har
Copyright 2023 Tero Karvinen http://TeroKarvinen.com .
GNU General Public License, version 3.
optional arguments:
-h, --help show this help message and exit
-v, --verbose
-d, --debug
-m MATCH, --match MATCH
Only extracts files matching regex.
-i INFILE, --infile INFILE
-o OUTDIR, --outdir OUTDIR
-f, --overwrite Overwrite HTML files if they already exist.
Copyright 2023 Tero Karvinen http://TeroKarvinen.com
HAR is just JSON
A HAR file just saves your browsing as a JSON file. Here is a sample from a start of a HAR file saved from Firefox.
{
"log": {
"version": "1.2",
"creator": {
"name": "Firefox",
"version": "123.9.0"
},
"browser": {
"name": "Firefox",
"version": "123.9.0"
},
"pages": [
{
"startedDateTime": "2023-02-26T14:04:12.086+00:00",
"id": "page_1",
"title": "Tero Karvinen - Learn Free software with me",
"pageTimings": {
"onContentLoad": 276,
"onLoad": 559
}
}
],
"entries": [
{
"pageref": "page_1",
"startedDateTime": "2023-02-27T14:04:12.086+00:00",
"request": {