New to Node so this might be an issue of not understanding Node well enough but basically I'm trying to scrape a list of titles on a page using Puppeteer. When I run the query in Chrome console I get a list of titles. Woo!
Array.from(document.querySelectorAll('div.description h3.title')).map(partner => partner.innerText)
(12) ["Jellyfish", "MightyHive", "Adswerve", "55 | fifty-five", "E-Nor", "LiveArea", "Merkle Inc.", "Publicis Sapient", "Acceleration Precision", "Resolute Digital", "PMG", "Kepler Group"]
But when I test it out in VS Code with Node.js I get an empty array
const browser = await puppeteer.launch();
const page = await browser.newPage();
const url =
"https://marketingplatform.google.com/about/partners/find-a-partner?utm_source=marketingplatform.google.com&utm_medium=et&utm_campaign=marketingplatform.google.com%2Fabout%2F";
await page.goto(url);
const titles = await page.evaluate(() =>
Array.from(document.querySelectorAll("h3.title"))
.map(partner => partner.innerText.trim())
)
$ Node google-test.js
[]
I've tried further specifying the selector even using the inspect 'copy selector' shortcut for an exact select but still get an empty Array.
If I am more vague such as selecting "h2" I get a result but once I further spec it's over for me. What gives?