extractClasses function

List<ClassRef> extractClasses(
  1. BeautifulSoup soup
)

Implementation

List<ClassRef> extractClasses(BeautifulSoup soup) {
  List<ClassRef> classes = [];
  Bs4Element? classTableParent =
      soup.find('div', id: "m_Content_listecontainer");
  if (classTableParent != null && classTableParent.children.isNotEmpty) {
    Bs4Element table = classTableParent.children.elementAt(0);
    for (var paragraph in table.children) {
      for (var group in paragraph.children) {
        String? href = group.attributes['href'];
        if (/*group.text.contains(RegExp(r'^\d[a-z]*[a-z]')) &&*/ href !=
            null) {
          String classId = queriesFromSoup(href)['klasseid'] ?? "";
          ClassRef classRef = ClassRef(name: group.text, id: classId);
          classes.add(classRef);
        }
      }
    }
  }
  return classes;
}