Skip to content

Instantly share code, notes, and snippets.

@gbit-is
Created May 18, 2024 16:16
Show Gist options
  • Save gbit-is/4d60a64badc8812e35620e40b00ac8dd to your computer and use it in GitHub Desktop.
Save gbit-is/4d60a64badc8812e35620e40b00ac8dd to your computer and use it in GitHub Desktop.
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