diff options
Diffstat (limited to 'skripti')
-rwxr-xr-x | skripti/poprbot.py | 12 |
1 files 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) |