From d048878e589f5595525a5006f6f483f767d08bc1 Mon Sep 17 00:00:00 2001 From: falsycat Date: Sun, 12 Feb 2023 10:58:49 +0900 Subject: [PATCH] fix an issue that cannot make a reservation --- mods/elicense.py | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/mods/elicense.py b/mods/elicense.py index 0dbde2e..8def240 100644 --- a/mods/elicense.py +++ b/mods/elicense.py @@ -22,6 +22,18 @@ class Mod: self.ss = self.authenticate() + def __del__(self): + res = self.ss.get( + url = self.URL+"logout.action", + params = { + "b.schoolCd": self.CONFIG["school"], + "senisakiCd": 4, + }) + res.encoding = "shift_jis" + self.calender = Calender(res.text) + + self.logging.info("logout succeeded") + def cycle(self): if len(self.targets) == 0: return @@ -30,7 +42,7 @@ class Mod: url = self.URL+"p04a.action", data = { "b.processCd": "A", - "b.kamokuCd" : 0, + "b.kamokuCd" : self.calender.params["kamokuCd"], "b.page" : 1, "b.schoolCd" : self.CONFIG["school"], }) @@ -62,12 +74,12 @@ class Mod: data = { "b.schoolCd" : self.CONFIG["school"], "b.processCd" : "V", - "b.kamokuCd" : 0, - "b.instructorTypeCd" : 0, + "b.kamokuCd" : self.calender.params["kamokuCd"], + "b.instructorTypeCd" : self.calender.params["instructorTypeCd"], "b.dateInformationType": date, "b.infoPeriodNumber" : slot, - "b.carModelCd" : self.calender.carModel, - "b.instructorCd" : 0, + "b.carModelCd" : self.calender.params["carModelCd"], + "b.instructorCd" : self.calender.params["instructorCd"], "b.page" : 1, "b.groupCd" : self.calender.group, }) @@ -108,6 +120,12 @@ class Calender: self.avails = re.findall(RE_AVAIL_SLOT, text) + self.params = {} + for name in RE_PARAMS: + m = re.search(RE_PARAMS[name], text) + if m is not None: + self.params[name] = m[1] + def checkAvailable(self, date, slot): for avail in self.avails: if avail[0] == date and avail[1] == str(slot): @@ -131,3 +149,14 @@ TIMETABLE = { RE_ALERT = re.compile(r"window\.alert\('(.*)'\)") RE_ERROR = re.compile(r"<.*? class=\"errorTitle\">メッセージ<\/.*?>\s*<.*? class=\"errorDisp\">(.*?)<\/.*?>", re.MULTILINE) RE_AVAIL_SLOT = re.compile(r"^\s*$") + +RE_PARAMS = { + "kamokuCd" : None, + "instructorTypeCd": None, + "carModelCd" : None, + "instructorCd" : None, + "groupCd" : None, +} +for name in RE_PARAMS: + RE_PARAMS[name] = re.compile( + r"