Ejemplo n.º 1
0
    def list_exam_grades(self):
        """ 获取等级考试成绩信息

        :rtype: list of dict
        :return: 列表,内容为每次等级考试的信息

        >>> zf.list_exam_grades()
        [
            {
                '学年': '2015-2016',
                '学期': 1,
                '等级考试名称': '全国大学英语四级考试',
                '准考证号': '320082152113313',
                '考试日期': datetime.datetime(2015, 12, 19, 0, 0),
                '成绩': '710'
                '写作成绩': '',
                '综合成绩': ''
            },
            ...
        ]
        """
        soup = self.get_soup(method='get', url=self.URLs.GRADE.format(account=self.account))
        table = soup.select_one('#DataGrid1')
        result = table_to_list(table, index_cast_dict={
            1: int,
            4: lambda x: datetime.strptime(x, '%Y%m%d')
        })
        return result
Ejemplo n.º 2
0
    def list_exam_scores(self):
        """获取参加过的考试的成绩列表

        :rtype: list[dict]
        :return: 返回一个包含考试成绩信息字典的列表, 注意是所有参加过的考试

        >>> zf.list_exam_scores()
        [
            {
                '备注': '',
                '学分': 3.0,
                '学年': '2016-2017',
                '学期': 1,
                '学院名称': '电子科学与工程学院',
                '成绩': 90.0,
                '绩点': 4.0,
                '补考成绩': '',
                '课程代码': 'B0400111S',
                '课程名称': '模拟电子线路C',
                '课程归属': '',
                '课程性质': '必修',
                '课程英文名称': '',
                '辅修标记': '0',
                '重修成绩': '',
                '重修标记': '0'
            },
            ...
        ]

        """
        viewstate = self.s._get_viewstate(url=self.URLs.SCORE.format(
            username=self.username))
        data = {
            'ddlXN': '',
            'ddlXQ': '',
            '__VIEWSTATE': viewstate,
            'Button2': '%D4%DA%D0%A3%D1%A7%CF%B0%B3%C9%BC%A8%B2%E9%D1%AF'
        }
        soup = self.s.get_soup(
            method='post',
            url=self.URLs.SCORE.format(username=self.username),
            data=data)
        table = soup.select_one('#Datagrid1')
        return table_to_list(table,
                             index_cast_dict={
                                 1: int,
                                 6: float,
                                 7: lambda x: float(x) if x else None,
                                 8: lambda x: float(x) if x.isdigit() else x
                             })
Ejemplo n.º 3
0
    def list_optional_courses(self):
        """获取可选课程列表,对应于教务系统 -> 网上选课 -> 学生选课

        :rtype: list of dict
        :return: 可选课程信息列表
        :raise: :class:`njupt.exceptions.TemporaryBannedException`
        """
        soup = self.get_soup(self.URLs.OPTIONAL_COURSES.format(account=self.account))
        if len(str(soup)) < 100:
            raise TemporaryBannedException('选课三秒防刷')
        table = soup.select_one('#kcmcgrid')
        result = table_to_list(table, remove_index_list=[8], index_cast_dict={
            4: int,
            9: int
        })
        return result[:-1]  # 最后多了一个空行