HAR Recording Guide
Learn to record and analyze HTTP Archive (HAR) files using browser DevTools.
What is HAR?
HAR (HTTP Archive) is a file format that logs browser interaction with a website. It captures all HTTP requests, responses, headers, cookies, and timing data.
Step-by-Step: Record a HAR File
- Open Chrome DevTools (F12 or right-click → Inspect)
- Go to the Network tab
- Make sure the recording button (red dot) is active
- Check "Preserve log" to keep entries across page navigations
- Navigate to the target page and interact with it
- Right-click on any request in the list
- Select "Save all as HAR with content"
Recommended Settings
- Preserve log: Enabled (keeps requests across navigations)
- Disable cache: Optional (captures fresh responses)
- Filter: Use XHR/Fetch filter for API requests
Path A: Analyze HAR with Python
# pip install haralyzer
from haralyzer import HarParser
with open('recording.har', 'r') as f:
har = HarParser(f.read())
for entry in har.entries:
print(f"URL: {entry.request.url}")
print(f"Method: {entry.request.method}")
print(f"Status: {entry.response.status}")
print(f"Content-Type: {entry.response.mimeType}")
print("---")
Path B: Extract data with json module
import json
with open('recording.har', 'r') as f:
har = json.load(f)
for entry in har['log']['entries']:
url = entry['request']['url']
method = entry['request']['method']
status = entry['response']['status']
content = entry['response']['content']
if 'application/json' in content.get('mimeType', ''):
data = json.loads(content['text'])
print(f"API: {url}")
print(f"Data: {json.dumps(data, indent=2, ensure_ascii=False)[:200]}")
AI Prompt Template
Use this prompt with ChatGPT or Claude:
I have a HAR file from visiting [WEBSITE_URL]. Help me:
1. Identify the API endpoint that returns [DATA_TYPE]
2. Extract the request headers needed (especially cookies/tokens)
3. Write Python code to replicate this request with requests library
4. Handle pagination if the data is split across multiple requests
Practice Target
Record a HAR while browsing the Movies page. You should see:
- Initial page load (HTML request)
- CSS and JS assets
- The
xl_sessioncookie being set - Any AJAX requests for dynamic content