fix an issue that cannot make a reservation

This commit is contained in:
falsycat 2023-02-12 10:58:49 +09:00
parent 07f78afdc4
commit d048878e58

View File

@ -22,6 +22,18 @@ class Mod:
self.ss = self.authenticate() 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): def cycle(self):
if len(self.targets) == 0: if len(self.targets) == 0:
return return
@ -30,7 +42,7 @@ class Mod:
url = self.URL+"p04a.action", url = self.URL+"p04a.action",
data = { data = {
"b.processCd": "A", "b.processCd": "A",
"b.kamokuCd" : 0, "b.kamokuCd" : self.calender.params["kamokuCd"],
"b.page" : 1, "b.page" : 1,
"b.schoolCd" : self.CONFIG["school"], "b.schoolCd" : self.CONFIG["school"],
}) })
@ -62,12 +74,12 @@ class Mod:
data = { data = {
"b.schoolCd" : self.CONFIG["school"], "b.schoolCd" : self.CONFIG["school"],
"b.processCd" : "V", "b.processCd" : "V",
"b.kamokuCd" : 0, "b.kamokuCd" : self.calender.params["kamokuCd"],
"b.instructorTypeCd" : 0, "b.instructorTypeCd" : self.calender.params["instructorTypeCd"],
"b.dateInformationType": date, "b.dateInformationType": date,
"b.infoPeriodNumber" : slot, "b.infoPeriodNumber" : slot,
"b.carModelCd" : self.calender.carModel, "b.carModelCd" : self.calender.params["carModelCd"],
"b.instructorCd" : 0, "b.instructorCd" : self.calender.params["instructorCd"],
"b.page" : 1, "b.page" : 1,
"b.groupCd" : self.calender.group, "b.groupCd" : self.calender.group,
}) })
@ -108,6 +120,12 @@ class Calender:
self.avails = re.findall(RE_AVAIL_SLOT, text) 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): def checkAvailable(self, date, slot):
for avail in self.avails: for avail in self.avails:
if avail[0] == date and avail[1] == str(slot): if avail[0] == date and avail[1] == str(slot):
@ -131,3 +149,14 @@ TIMETABLE = {
RE_ALERT = re.compile(r"window\.alert\('(.*)'\)") RE_ALERT = re.compile(r"window\.alert\('(.*)'\)")
RE_ERROR = re.compile(r"<.*? class=\"errorTitle\">メッセージ<\/.*?>\s*<.*? class=\"errorDisp\">(.*?)<\/.*?>", re.MULTILINE) RE_ERROR = re.compile(r"<.*? class=\"errorTitle\">メッセージ<\/.*?>\s*<.*? class=\"errorDisp\">(.*?)<\/.*?>", re.MULTILINE)
RE_AVAIL_SLOT = re.compile(r"^\s*<a href=\"#\" onclick=\"sendContent\('(\d+)','(\d+)','V',document\.getElementById\('formId'\)\)\">$") RE_AVAIL_SLOT = re.compile(r"^\s*<a href=\"#\" onclick=\"sendContent\('(\d+)','(\d+)','V',document\.getElementById\('formId'\)\)\">$")
RE_PARAMS = {
"kamokuCd" : None,
"instructorTypeCd": None,
"carModelCd" : None,
"instructorCd" : None,
"groupCd" : None,
}
for name in RE_PARAMS:
RE_PARAMS[name] = re.compile(
r"<input type=\"hidden\" name=\"b.{0}\" value=\"(.*?)\" id=\"".format(name))