Created
June 6, 2019 20:17
-
-
Save stucka/ff2e5e96729b864bd3bdc34a0eeed05c to your computer and use it in GitHub Desktop.
Download data from PANDA install -- something something news data appliance
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
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