embalses visibles, lógica adecuada, necesidad de cambios en interfaz
This commit is contained in:
@ -15,6 +15,26 @@ class MyBloc extends Cubit<MyState> {
|
||||
MyBloc() : super(MyState());
|
||||
|
||||
}
|
||||
//mejorar código
|
||||
Future<List<String>> obtenerDatos(String url) async {
|
||||
final response = await http.get(Uri.parse('http://www.crcivan.com/escaparate/noticias.cgi?idnoticias=192683'));
|
||||
if (response.statusCode == 200) {
|
||||
final document = htmlParser.parse(response.body);
|
||||
final elementosSpan = document.querySelectorAll('html > body > div > center > table > tbody > tr > td > div > center > table > tbody > tr > td > table > tbody > tr > td > font > font > table > tbody > tr > td > span');
|
||||
List<String> embalsesData = [];
|
||||
|
||||
for (var elemento in elementosSpan) {
|
||||
final style = elemento.attributes['style'];
|
||||
if (style != null && style.contains('color: #000000; font-size: 12pt;')) {
|
||||
embalsesData.add(elemento.text);
|
||||
}
|
||||
}
|
||||
|
||||
return embalsesData;
|
||||
} else {
|
||||
throw Exception('Error al cargar los datos de embalses');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> launchAemetURL() async {
|
||||
const urlString = 'https://www.aemet.es/es/eltiempo/prediccion/municipios/caspe-id50074';
|
||||
|
||||
Reference in New Issue
Block a user