web_scraper
web_scraper copied to clipboard
Problem in the nth-child of even indexes
All even indexes are not found in the method below
Future<void> loadPage() async {
webScraper = WebScraper();
if (await webScraper.loadFullURL('https://www.agricultura.go.gov.br/noticias.html')) {
try {
var elements1_ok = webScraper.getElementTitle('div.g-grid.item:nth-child(1) > div > a > h2.heading');
elements1_ok.forEach((img) => print(img));
var elements2_notFound = webScraper.getElementTitle('div.g-grid.item:nth-child(2) > div > a > h2.heading');
elements2_notFound.forEach((img) => print(img));
var elements3_ok = webScraper.getElementTitle('div.g-grid.item:nth-child(3) > div > a > h2.heading');
elements3_ok.forEach((img) => print(img));
var elements4_notFound = webScraper.getElementTitle('div.g-grid.item:nth-child(4) > div > a > h2.heading');
elements4_notFound.forEach((img) => print(img));
} catch (e) {
print(e);
}
}
}
Details: nth-child (2) returns the empty value nth-child (3) returns the value nth-child (2) The same is happening for all elements of the list
I have the same problem
it seems to be a problem with dom.dart we forked and used universal html and it worked!
Hi @Laestry! Would you like to contribute for the same?