Created
January 29, 2020 10:44
-
-
Save jpswade/3549a4ce7af573a0a7112f6016bf5abd to your computer and use it in GitHub Desktop.
Parse the json
This file contains 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
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