Created
May 18, 2024 16:16
-
-
Save gbit-is/4d60a64badc8812e35620e40b00ac8dd to your computer and use it in GitHub Desktop.
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 requests | |
import json | |
url = "https://kisildalur.is/api/categories/12?includes=sub_public_categories,sub_public_categories.media,public_products,public_products.media,public_products.sub_products,public_products.sub_products.categorie" | |
url = "http://localhost:8000/kisildalur.html" | |
def pprint(msg): | |
try: | |
print(json.dumps(msg,indent=2)) | |
except: | |
print(msg) | |
def get_json_data(url): | |
r = requests.get(url) | |
json_data = r.json() | |
return json_data | |
def parse_json_data(json_data): | |
products = [ ] | |
for entry in json_data["public_products"]: | |
del entry["description"] | |
if "rzy" in entry["properties"]: | |
if entry["properties"]["rzy"]["name"] == "Fylgihlutir": | |
continue | |
products.append(entry) | |
return products | |
json_data = get_json_data(url) | |
parsed_json_data = parse_json_data(json_data) | |
pprint(parsed_json_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment