A command-line tool to extract and save all files, API responses, and web assets from a HAR (.har) archive.
This script addresses the common need to extract all resources from a web session for offline analysis, debugging, or bulk downloading. Manually saving each file from a browser's developer tools is tedious and impractical, especially for modern web applications with numerous API calls and dynamically loaded assets.
This tool automates the entire process: simply save your network activity as a HAR file, and this script will unpack everything into a local directory for you.
- Automatic HAR Parsing: Natively processes standard
.harfiles without any configuration. - Base64 Decoding: Automatically detects and decodes Base64 encoded content, typically used for images and fonts.
- Filename Sanitization: Cleans filenames by removing characters that are illegal in common operating systems (
\ / : * ? " < > |), ensuring cross-platform compatibility. - Handles Ambiguous URLs: Generates logical default filenames for requests that don't point to a specific file (e.g., API endpoints like
/api/user/123). - Zero Dependencies: Uses only Python's standard library. No
pip installrequired. - Simple CLI: A straightforward command-line interface for easy operation.
First, you need to capture the network activity from your browser and save it as a .har file.
- On the target website, open your browser's Developer Tools (usually by pressing
F12). - Navigate to the Network tab.
- Ensure the "Preserve log" option is checked if you need to capture activity across multiple pages.
- Perform the actions on the website that you want to record (e.g., refresh the page, click buttons, submit forms).
- Once you see the network requests appear in the log, right-click anywhere on the list of requests.
- Select "Save all as HAR with content".
- Save the file to your computer (e.g.,
my_archive.har).
Place the har_extractor.py script in the same directory as your .har file, or ensure it's in your system's PATH. Open your terminal or command prompt and run the script.
Basic Usage
This command will read my_archive.har and save all extracted files into a new folder named output in the current directory.
python har_extractor.py my_archive.harSpecifying an Output Directory
Use the -o or --output flag to save files to a custom directory.
python har_extractor.py my_archive.har --output ./downloaded_assetsGet Help
To see all available options, use the --help flag.
python har_extractor.py --helpBefore: Your directory contains the script and the captured HAR file.
/my-project
├── har_extractor.py
└── example.har
After running python har_extractor.py example.har:
The script creates an output directory and populates it with the extracted content.
/my-project
├── har_extractor.py
├── example.har
└── output/ <-- Automatically created
├── index.html
├── style.css
├── logo.png
└── user?id=123&type=customer
This project is licensed under the MIT License.