From 1cc9b4334615c1224dead7a8cc7c7ce18ca46150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sat, 3 Feb 2024 11:06:48 +0100 Subject: guanxi --- skripti/poprbot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/skripti/poprbot.py b/skripti/poprbot.py index a32101d..2c8efe7 100755 --- a/skripti/poprbot.py +++ b/skripti/poprbot.py @@ -8,7 +8,7 @@ from time import sleep from bs4 import BeautifulSoup popr = "https://popr.uni-lj.si/" def prijavi_se(s, event, slotid): - form = BeautifulSoup(s.get(popr + "student/events.html?page=booking&id=14564&slotId=44840&bookingAction=BOOK").text, features="lxml").find("form") + form = BeautifulSoup(s.get(popr + "student/events.html?page=booking&id=" + str(event) + "&slotId=" + str(slotid) + "&bookingAction=BOOK").text, features="lxml").find("form") dejta = "_eventId_book=Submit" for inp in form.findAll("input"): try: @@ -17,6 +17,7 @@ def prijavi_se(s, event, slotid): pass s.post(popr + "student/events.html", data=dejta, headers={"Content-Type": "application/x-www-form-urlencoded"}) def get_event(s, event): + s.get(popr + "student/svc/events.html") # session keepalive jwt = s.get(popr + "api/user/token/refresh").text s.headers.update({"Authorization": "Bearer " + jwt}); return json.loads(s.get(popr + "ext/svc/events-api-0-0/events/user/event/slots/" + event + "?locale=en").text)[0]; @@ -28,11 +29,12 @@ def main(): slot = None if len(argv) >= 3: slot = int(argv[2]) - if getenv("JSESSIONID") == None: - print("Okoljska spremenljivka JSESSIONID naj vsebuje vrednost istoimenskega piškotka.") + if getenv("COOKIES") == None: + print("Okoljska spremenljivka COOKIES naj vsebuje piškotke v obliki ime=vrednost;ime2=vrednost2;... Potrebujete dva piškotka -- GUANXI_GUARD_SERVICE_PROVIDER... in JSESSION") return s = requests.Session() - s.cookies.set("JSESSIONID", getenv("JSESSIONID")); + for pair in getenv("COOKIES").split(";"): + s.cookies.set(pair.split("=")[0], pair.split("=")[1]); ev = get_event(s, event) slotid = ev["slots"][0]["id"] if len(ev["slots"]) > 1 and slot == None: @@ -55,6 +57,8 @@ def main(): ev2 = get_event(s, event); if ev2 != ev: print("NAPAKA! Dogodek se je spremenil!") + print("prejšnji: " + ev) + print("trenutni: " + ev2) return sleep(180) sleep((kdaj-datetime.now()).total_seconds()-3) -- cgit v1.2.3