def _fetch_courses(self):
body = "SERVICE=SCRIPTER&REPORT=WEB31&SCRIPT=SD2GETAUD%%26ContentType%%3Dxml&ACTION=REVAUDIT&ContentType=xml&STUID=%s&DEBUG=OFF" % (self.studentID)
r = requests.post(self.url, cookies=self.cookies, data=body)
soup = BeautifulSoup(r.text, 'lxml')
block = soup.find('block')
self.units_applied = float(block['credits_applied'])
for goal in soup.find('deginfo').findAll('goal'):
if goal['code'].lower() == 'major':
self.major.append(goal['valuelit'])
elif goal['code'].lower() == 'minor':
self.minor.append(goal['valuelit'])
elif goal['code'].lower() == 'spec':
self.spec.append(goal['valuelit'])
classes = soup.find("clsinfo")
for cls in classes.findAll("class"):
disc, num = '', ''
if len(cls.get('disc', '')) > 0:
disc = cls['disc']
elif len(cls.get('discipline', '')) > 0:
disc = cls['discipline']
if len(cls.get('num', '')) > 0:
num = cls['num']
elif len(cls.get('number', '')) > 0:
num = cls['number']
if len(disc) > 0 and len(num) > 0:
self.classes.add(disc + ' ' + num)
# check for each requirement
for rule in soup.find_all('rule', attrs={'indentlevel':'1'}):
if rule and type(rule) == element.Tag \
and rule['ruletype'] in allowed_rule_type and rule['per_complete'] not in disallowed_per_complete:
ge = re.match(ge_filter, rule.get('label', ''))
if not ge:
continue
self.ge_table['GE'+ge.group(1)] = self.checkRequirement(rule)
# for development purpose, print out how many classes are missing for each requirement
print ('@@@', 'GE'+ge.group(1), 'missing', self.ge_table['GE'+ge.group(1)], 'courses')
# return total missing courses for this rule
评论列表
文章目录