Skip to content

Instantly share code, notes, and snippets.

@stucka
Created June 6, 2019 20:17
Show Gist options
  • Save stucka/ff2e5e96729b864bd3bdc34a0eeed05c to your computer and use it in GitHub Desktop.
Save stucka/ff2e5e96729b864bd3bdc34a0eeed05c to your computer and use it in GitHub Desktop.
Download data from PANDA install -- something something news data appliance
import requests # External dependency
from tqdm import tqdm # External dependency
import json
username = "[email protected]"
apikey = "abcdefghijklmnopqrstuvwxyz01234567890123"
baseurl = "http://something.compute-1.amazonaws.com"
urlsuffix = f"?format=json&email={username}&api_key={apikey}"
r = requests.get(f"{baseurl}/api/1.0/export/{urlsuffix}")
projectsraw = json.loads(r.text)
objectids = {}
for myobject in projectsraw['objects']:
objectids[myobject['id']] = myobject['filename']
# http://localhost:8000/api/1.0/export/[id]/download/
for myobject in tqdm(objectids):
filename = objectids[myobject].replace(":", "_")
with open(filename, "wb") as f:
r = requests.get(f"{baseurl}/api/1.0/export/{myobject}/download/{urlsuffix}")
if r.status_code == 200:
f.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment