DEV Community

Omer
Omer

Posted on

How to grab all titles of products from an Amazon page

I'm trying to scrap all the titles from this address:
https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dsporting-intl-ship&field-keywords=&crid=1DOOCWEG8BVJ7&sprefix=%2Csporting-intl-ship%2C216
by this code:
const productHandles = await page.$$(
"div.a-section.a-spacing-medium.octopus-search-result-card_style_apbSearchResultsContainer_bCqjb > .apb-default-slot .apb-default-search-results"
);
for (const productHandle of productHandles) {
const title = await page.evaluate(
(el) => el.querySelector("h2 > a > span").textContent,
productHandle
);
console.log(title);
}

but all i get is the first product title ("Band-Aid Brand Flexible Fabric Adhesive Bandages for Wound Care and First Aid, All One Size, 100 Count")

Top comments (0)