Skip to content

Instantly share code, notes, and snippets.

@brunogfranca
Created July 20, 2020 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunogfranca/8106f7a7927747bb601f47acc9cb3dfd to your computer and use it in GitHub Desktop.
Save brunogfranca/8106f7a7927747bb601f47acc9cb3dfd to your computer and use it in GitHub Desktop.
import json
from urllib.parse import urlparse
def parse_har(filename):
with open(filename) as h:
data = json.loads(h.read())
urls = list(set([i['request']['url'] for i in data['log']['entries']]))
domains = list(set([urlparse(i).netloc for i in urls]))
with open(f'{filename}.urls.csv', 'w+') as h:
for url in urls:
h.write(f'{url}\n')
with open(f'{filename}.domains.csv', 'w+') as h:
for domain in domains:
h.write(f'{domain}\n')
parse_har('stoodi-video.har')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment