Here, I am trying to get each players runs and matches using player-URL.
When I passes selector within page.$$eval
method and in callback element when I console it,I got nothing in it.
const stats = await page.$$eval(
"div.score-top.sp.text-center > div.container > div.match-summary > div.row > div.col-sm-12 > div.match-in-summary > div.row > div.col-sm-5 > div.matches-runs-wickets > ul.list-inline ",
(elements) => {
console.log("elements", elements);
return elements.map((match) => {
return (obj = {
matches: match.querySelector(" li:nth-Child(1) >span").innerText,
runs: match.querySelector("li:nth-Child(2) > span").innerText,
});
});
}
);
return stats;
}
but when I map over the callback element and return the object then I am getting runs and matches in stats variableThe code detail is mentioned here.