Skip to content

Instantly share code, notes, and snippets.

@jpswade
Created January 29, 2020 10:44
Show Gist options
  • Save jpswade/3549a4ce7af573a0a7112f6016bf5abd to your computer and use it in GitHub Desktop.
Save jpswade/3549a4ce7af573a0a7112f6016bf5abd to your computer and use it in GitHub Desktop.
Parse the json
import json
import re
filepath = 'sample.html'
file = open(filepath, 'r')
body = file.read()
matches = re.findall(r'<script>window.jsonModel = (.+?)</script>', body)
blob = json.loads(matches[0])
print(json.dumps(blob, indent=4, sort_keys=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment