Last active
November 26, 2025 17:18
-
-
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...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # !/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
I think the shebang is wrong, it needs the space removed before the "!".
This line:
Should be changed to:
In it's current state, if I
chmod u+x chrome_websocket_messages.pythen./chrome_websocket_messages.pyI think bash can't read the shebang and guesses that it should run the file with imagemagick.