我试图用puppeteer废弃一些数据,但对于一些网站querySelector返回null,我不知道有什么问题.我在stackoverflow中找到了关于这个问题的一些答案,但没有一个有效.这是带有示例链接的代码不起作用.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.macys.com/shop/product/the-north-face-mens-
logo-half-dome-t-shirt?ID=2085687&CategoryID=30423&cm_kws=2085687');
const textContent = await page.evaluate(() => {
return document.querySelector('.price');
});
console.log(textContent);
browser.close();
})();
Run Code Online (Sandbox Code Playgroud)