getAllGroupsFuture function
Implementation
Future<List<Group>> getAllGroupsFuture() async {
List<Group> groupsList = [];
final response =
await http.Client().get(Uri.parse(GlobalVariable.URL_MAIN + "/cg.htm"));
if (response.statusCode == 200) {
var body = decodeCp1251(response.body);
var document = parse(body, encoding: 'windows-1251');
var table = document
.getElementsByClassName("inf")[0]
.getElementsByTagName("tbody")[0];
var res = table.getElementsByTagName("tr").length - 1;
for (int i = 1; i <= res; i++) {
var nameGroup = table
.getElementsByTagName("tr")[i]
.getElementsByTagName("td")[1]
.text;
var linkGroup = table
.getElementsByTagName("tr")[i]
.getElementsByTagName("td")[1]
.getElementsByTagName("a")[0]
.attributes;
groupsList.add(Group(nameGroup, linkGroup["href"].toString()));
}
}
return groupsList;
}