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

  1. Open Chrome DevTools (F12 or right-click → Inspect)
  2. Go to the Network tab
  3. Make sure the recording button (red dot) is active
  4. Check "Preserve log" to keep entries across page navigations
  5. Navigate to the target page and interact with it
  6. Right-click on any request in the list
  7. Select "Save all as HAR with content"

Recommended Settings

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: