graphPaname/app/request_datasets.py

29 lines
642 B
Python

from constants import datasets, url
from requests import get
from constants import datasets, url, filenames
from requests import get, codes
from json import dump, dumps
def save_json(data, filename):
data_dir = "data/"
with open(data_dir + filename + ".json", "w") as f:
dump(data, f, ensure_ascii=False)
def request_dataset(url, filename):
response = get(url)
response.raise_for_status()
data = response.json()
save_json(data, filename)
def format_url():
for set in datasets:
link = url.format(set)
request_dataset(link, filenames[set])
if __name__ == "__main__":
format_url()