constructFromCeleneInfo static method

Course? constructFromCeleneInfo(
  1. Bs4Element data, {
  2. String? parent,
})

Transforme un élément html depuis la page celene vers une cours

Implementation

static Course? constructFromCeleneInfo(Bs4Element data,{String? parent}){
  Bs4Element? courseAtag = data.find("a",class_: "aalink stretched-link");
  logger("Course topic ! ${parent}");
  if (courseAtag != null){
    String? courseLink = courseAtag.getAttrValue("href");
    Bs4Element? span = courseAtag.find("span", class_: "instancename");
    if (span != null){
      Bs4Element? accessHide = span.find("span", class_: "accesshide");
      if (accessHide != null && courseLink != null){
        String courseType = accessHide.getText(strip: true);
        accessHide.decompose();
        String courseName = span.getText(strip: true);

        return Course(courseName,courseLink, courseType,topic: parent);
      }
    }
  }
  return null;
}