Files
hacklist/hackculture.py
T

45 lines
1.3 KiB
Python

# import requests
from datetime import datetime
import json
# response = requests.get(
# "https://api.hackculture.io/api/v1/hackathons?limit=50&response_type=card&sort_by=start_datetime&sort_order=-1",
# 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://hackculture.io",
# "Referer": "https://hackculture.io/",
# },
# )
#
# with open("hackculture.json", "w", encoding="utf-8") as file:
# file.write(response.text)
with open("hackculture.json") as file:
hackathons = json.loads(file.read())
# print(hackathons[0])
for hackathon in hackathons:
if not hackathon["is_registration_open"] or hackathon["type"] != "hackathon":
continue
name = hackathon["name"]
org = hackathon["organizer_name"]
location = None
if hackathon["location"]:
location = hackathon["location"]["name"]
if hackathon["location"]["address"]:
location += ", " + hackathon["location"]["address"]
event_date = datetime.fromisoformat(hackathon["end_datetime"])
print(name)
print(f"Organizer: {org}")
print(f"Location: {location}")
print(f"Event Date: {event_date.date()}")
print()