students_list.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:MSTU_scraper 作者: rrr3371 项目源码 文件源码
def get_students(self):
        group = self.group
        group_name = group[:group.find('(')].strip()
        group_code = group[group.find('(')+1:group.find(')')]

        students = []
        for row in self.table.children:
            if type(row) == NavigableString:
                continue

            active = True
            link = row.find(class_='fio_3').parent
            if link.has_attr('style') and link['style'] == 'color:gray;': #????? ?????? - ??????? ????????
                active = False
            student_id = parse_qs(urlparse(link['href']).query)['sid'][0]

            name = row.find(class_='fio_3').string.strip()
            record_book_id = row.find(class_='hc3').string.strip()

            name = " ".join(name.split())
            record_book_id  = " ".join(record_book_id.split())
            students.append({'name': name, 'id': student_id, 'record_book': record_book_id, 'active': int(active)})

        return {'group': group_name, 'code': group_code, 'students': students, 'id': self.group_id}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号