I wanted to create an app that would tell me weather information, taken from a webscraping.
I made this code and I have no idea why it's giving me "Instance of 'Future'" instead of my value:
import 'package:html/dom.dart' as dom;
import 'package:html/parser.dart' as parser;
import 'package:http/http.dart' as http;
class Scraper {
List temp = [];
Future getData(city) async {
final response = await http
.get(Uri.parse('https://www.google.com/search?q=temperature+$city'));
dom.Document document = parser.parse(response.body);
var idTemp = document.getElementById('wob_tm');
return idTemp;
}
}
void main() {
var tempe = Scraper().getData('São Paulo');
print(tempe);
}
Why didn't my code work?