Skip to content

Instantly share code, notes, and snippets.

@fyxme
Created December 5, 2023 05:29
Show Gist options
  • Save fyxme/f89cd35fb3ea2e7d0dd09cc0027b326e to your computer and use it in GitHub Desktop.
Save fyxme/f89cd35fb3ea2e7d0dd09cc0027b326e to your computer and use it in GitHub Desktop.
Print HAR file endpoints (METHOD + URL)
#!/usr/bin/env python
# yonked 95% from https://gist.github.com/craSH/892479/raw/21d5c3222739743cad6e6e5c5f1597daecbe560e/har_response_urls.py
#
# Running more than one file: (Cbf updating this script even thought it would be trivial)
# IFS=$'\n'
# for f in `find .. | grep har`; do ./har_response_urls.py "$f"; done | tee all.txt
import json
if '__main__' == __name__:
import sys
if len(sys.argv) < 2:
print "Usage: %s <har_file>" % sys.argv[0]
sys.exit(1)
har_file = sys.argv[1]
# Read HAR archive (skip over binary header if present)
har_data = open(har_file, 'rb').read()
skip = 3 if '\xef\xbb\xbf' == har_data[:3] else 0
har = json.loads(har_data[skip:])
matching_entries = har['log']['entries']
matching_urls = set(map(lambda x: x['request']['method'] + " " + x['request']['url'], matching_entries))
for url in matching_urls:
print url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment