41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
# **************************************************************************** #
|
|
# #
|
|
# ::: :::::::: #
|
|
# 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);
|