initial commit

This commit is contained in:
2025-03-28 13:16:59 +01:00
commit f48aa34bc0
3 changed files with 179 additions and 0 deletions

40
scrap.py Normal file
View File

@ -0,0 +1,40 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# scrap.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/11/25 16:39:19 by tomoron #+# #+# #
# Updated: 2025/03/28 13:13:48 by tomoron ### ########.fr #
# #
# **************************************************************************** #
from login import Intra42
from getpass import getpass
import re
import json
import threading
import time
import sys
import dateutil
from datetime import date, timedelta
if(len(sys.argv) != 2):
print("missing team id, usage :", sys.argv[0], "<project_id>")
exit(1);
project_id = sys.argv[1]
start_search_date = date.today().strftime("%Y-%m-%d")
end_search_date = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
getUrl = f"https://projects.intra.42.fr/projects/{project_id}/slots.json?start={start_search_date}&end={end_search_date}"
connIntra = Intra42()
found = set();
while(True):
res = connIntra.get_available_slot(getUrl)
for x in res:
if x["ids"] not in found:
start = dateutil.parser.isoparse(x["start"]).strftime("%d/%m %H:%M")
end = dateutil.parser.isoparse(x["end"]).strftime("%d/%m %H:%M")
print("\aslot found starting at", start, ",ending at", end);
found.add(x["ids"])
time.sleep(1);