Skip to content

Instantly share code, notes, and snippets.

@AlJohri
Created January 10, 2018 03:58
Show Gist options
  • Select an option

  • Save AlJohri/0ff2570ecf2e3316ec7c9dead6d78ee7 to your computer and use it in GitHub Desktop.

Select an option

Save AlJohri/0ff2570ecf2e3316ec7c9dead6d78ee7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
import re
import json
import requests
import execjs
response = requests.get("https://obamawhitehouse.archives.gov/interactive-budget")
m = re.search(r"//init data(.*)//init TreeMap", response.text, re.S)
js = m.groups()[0].replace('var json = ', '').replace(';', '')
data = execjs.eval(js)
with open('input.json', 'w') as f:
json.dump(data, f, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment