feat: add api aggregations
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
# import requests
|
||||
from datetime import datetime
|
||||
import json
|
||||
# import re
|
||||
|
||||
# response = requests.get(
|
||||
# "https://reskilll.com/discover",
|
||||
# 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"
|
||||
# ),
|
||||
# },
|
||||
# )
|
||||
#
|
||||
#
|
||||
# def strip_undefined(obj):
|
||||
# if isinstance(obj, dict):
|
||||
# return {k: strip_undefined(v) for k, v in obj.items() if v != "$undefined"}
|
||||
# elif isinstance(obj, list):
|
||||
# return [strip_undefined(element) for element in obj]
|
||||
# return obj
|
||||
#
|
||||
#
|
||||
# def extract_data(html):
|
||||
# match = re.search(r'\\"initialData\\":(\[.*?\])\}\]\]', html, re.DOTALL)
|
||||
# if match:
|
||||
# return strip_undefined(
|
||||
# json.loads(bytes(match.group(1), "utf-8").decode("unicode_escape"))
|
||||
# )
|
||||
# return None
|
||||
#
|
||||
# with open("reskilll.json", "w", encoding="utf-8") as file:
|
||||
# file.write(json.dumps(extract_data(response.text)))
|
||||
|
||||
with open("reskilll.json") as file:
|
||||
hackathons = json.loads(file.read())
|
||||
|
||||
for hackathon in hackathons:
|
||||
name = hackathon["title"]
|
||||
org = hackathon["organizer"]
|
||||
location = hackathon["location"]
|
||||
reg_end = datetime.strptime(hackathon["deadline"], "%b %d, %Y")
|
||||
|
||||
if reg_end.timestamp() < datetime.now().timestamp():
|
||||
continue
|
||||
|
||||
print(name)
|
||||
print(f"Organizer: {org}")
|
||||
print(f"Location: {location}")
|
||||
print(f"Registration End: {reg_end.date()}")
|
||||
print()
|
||||
Reference in New Issue
Block a user