I'm trying to scrape data from a webpage. I wanted to get the URL present inside the style attribute(as marked in picture)
So far I tried his but it returns me empty strings
import 'dart:convert';
import 'package:html/dom.dart' as dom;
import 'package:html/parser.dart' as parser;
import 'package:http/http.dart' as http;
Future initiate() async {
final response = await http.get('https://pixxelprecision.co.uk/portfolio');
dom.Document document = parser.parse(response.body);
final imgUrl = document.getElementsByClassName('w-ibanner-image');
imgUrls = imgUrl.map((element) => element.attributes['style']).toList();
print('URLs: $imgUrls');
}
style
attribute initially has no value. Value is set by JS while page rendering. You can try to scrape @data-bg
instead:
imgUrls = imgUrl.map((element) => element.attributes['data-bg']).toList();