Searching within returned element
I have code like so to gather information about all item listings on a page and return them:
const resultsArr = await page.$$eval('.result-row', elements =>
elements.map(el => {
return {
price: await page.eval('how do I search within the element el?')
}
})
);
Testing in the chrome console I can get the elements and do something like
elements[0].find('.result-price')[0].innerHTML // returns '$1,500'
I am having a hard time translating my jquery into puppeteer. The question is, in the above example, how can I search and return data from element el
?
use page.evaluate
const resultsArr = await page.evaluate(() => {
return Array.from(document.querySelectorAll('.result-row .result-price')).map(el => {
return {
price: el.innerText
};
});
});