# import requests from datetime import datetime import json # response = requests.post( # "https://api.devfolio.co/api/search/hackathons", # headers={ # "User-Agent": ( # "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " # "AppleWebKit/537.36 (KHTML, like Gecko) " # "Chrome/151.0.0.0 Safari/537.36" # ), # "Origin": "https://devfolio.co", # "Referer": "https://devfolio.co/", # }, # json={ # "type": "application_open", # "from": 0, # "size": 100, # }, # ) # # hackathons = list(map(lambda v: v["_source"], response.json()["hits"]["hits"])) # with open("devfolio.json", "w", encoding="utf-8") as file: # file.write(response.text) with open("devfolio.json") as file: hackathons = list( map(lambda v: v["_source"], json.loads(file.read())["hits"]["hits"]) ) # print(hackathons[0]) for hackathon in hackathons: name = hackathon["name"] location = hackathon["location"] event_date = datetime.fromisoformat(hackathon["starts_at"]).date() reg_start = datetime.fromisoformat( hackathon["hackathon_setting"]["reg_starts_at"] ).date() reg_end = datetime.fromisoformat( hackathon["hackathon_setting"]["reg_ends_at"] ).date() print(name) print(f"Location: {location}") print(f"Event Date: {event_date}") print(f"Registration: {reg_start} - {reg_end}") print()