Skip to content

Instantly share code, notes, and snippets.

@achmel
Last active March 16, 2024 03:24
Show Gist options
  • Save achmel/e189ad4b8b4e28c235796994fe2cb68e to your computer and use it in GitHub Desktop.
Save achmel/e189ad4b8b4e28c235796994fe2cb68e to your computer and use it in GitHub Desktop.
Tiny parser to get websocket messages from Google Chrome Developer Tools > Network > Export HAR...
# !/usr/bin/env python3
# encoding: utf-8
import json
file_name = 'websocket.har'
f = open(file_name)
j = json.load(f)
entries = j['log']['entries']
for e in entries:
if e['_resourceType'] == 'websocket' and '_webSocketMessages' in e.keys():
messages = e['_webSocketMessages']
for m in messages:
if len(m['data']) > 1:
print(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment