Brenton Cleeland

Unique domains from a HAR file [snippet]

Published on

Python snippet to grab the unique domains that are requested in a HAR file. You can generally export a HAR file from the developer tools in your browser.

The HAR file itself is just a (very large) JSON document.

import json
har_json = json.load(open("harfile.har"))
print("\n".join(
    set([
        e["request"]["url"].split("//")[1].split("/")[0]
        for e in har_json["log"]["entries"]
    ])))