Skip to content

Instantly share code, notes, and snippets.

@cfra
Created June 30, 2021 13:03
Show Gist options
  • Save cfra/87af6a38b7a665a600d580ce4fdfff19 to your computer and use it in GitHub Desktop.
Save cfra/87af6a38b7a665a600d580ce4fdfff19 to your computer and use it in GitHub Desktop.
Extract Hosts from HAR
#!/usr/bin/env python3
import json
import sys
try:
file_path = sys.argv[1]
except IndexError:
sys.stderr.write(f"Usage: {sys.argv[0]} <file_path>\n")
sys.exit(1)
with open(file_path) as f:
doc = json.load(f)
print(set([ header['value']
for entry in doc['log']['entries']
for header in entry['request']['headers']
if header['name'] == 'Host'
]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment