extractTeams function

List<Team> extractTeams(
  1. BeautifulSoup soup
)

Implementation

List<Team> extractTeams(BeautifulSoup soup) {
  List<Team> teams = [];
  Bs4Element? table =
      soup.find('*', id: 's_m_Content_Content_HoldAndGroupList');

  if (table != null) {
    List<Bs4Element> tRows = table.findAll('tr', class_: 'textTop textLeft');
    if (tRows.isNotEmpty) {
      List<Bs4Element> teamRows = tRows[0].children[1].children[0].children;
      for (var teamRow in teamRows) {
        var linkEl = teamRow.find('a')!;
        var name = linkEl.text;
        var id =
            queriesFromSoup(linkEl.getAttrValue('href')!)['holdelementid']!;
        teams.add(Team(name: name, id: id, displayName: name));
      }
    }
  }
  return teams;
}