我在 Puppeteer 方面遇到了一些问题,我想提取一个项目列表,并在 headless 为 FALSE 时成功,但在为 TRUE 时则不然。
首先,我想在映射之前获取这些元素。
这是我的脚本,也许你可以复制它,它非常基本。
const chalk = require("chalk");
const baseUrl = "https://www.interencheres.com/recherche/lots?search=";
const searchTerm = "Apple";
const searchUrl = baseUrl + searchTerm;
(async () => {
const browser = await puppeteer.launch({
headless: false,
ignoreHTTPSErrors: true,
args: [`--window-size=1920,1080`],
defaultViewport: {
width: 1920,
height: 1080,
},
});
const page = await browser.newPage();
// Begin navigation
console.log(chalk.yellow("Beginning navigation."));
await page.goto(searchUrl);
// Await List of elements;
console.log(chalk.yellow("Wait for Network Idle..."));
await page.waitForNetworkIdle();
// get Items
const findElements …Run Code Online (Sandbox Code Playgroud)