Google chrome devtools 木偶演员在使用无头假木偶时

Google chrome devtools 木偶演员在使用无头假木偶时,google-chrome-devtools,puppeteer,chromium,Google Chrome Devtools,Puppeteer,Chromium,我有一个脚本来解析一个特定的网页。 当我将headless设置为false时,木偶演员不会加载页面 await page.goto('https://www.google.com', { waitUntil: 'load', // Remove the timeout timeout: 0 }); 我尝试了很多配置,比如: const args = [ '--no-sandbox',

我有一个脚本来解析一个特定的网页。 当我将headless设置为false时,木偶演员不会加载页面

 await page.goto('https://www.google.com', {
            waitUntil: 'load',
            // Remove the timeout
            timeout: 0
        });
我尝试了很多配置,比如:

 const args = [
        '--no-sandbox',
        '--enable-logging',
        ' --v=1',
        '--disable-gpu',
        '--disable-extension',
        '--disable-setuid-sandbox',
        '--disable-infobars',
        '--window-position=0,0',
        '--ignore-certifcate-errors',
        '--ignore-certifcate-errors-spki-list',
        '--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"'
    ];



    const options = {
        args,
        headless: false, // default is true
        userDataDir: "./user_data",
        defaultViewport: null,
        devtools: true,
        ignoreHTTPSErrors: true,
    };

但是脚本会停下来等待页面。转到直到超时。

据我所知,您不是在解析
google.com
页面。 首先应该考虑的是
waitill:'load'
。它所做的是,当加载事件被触发时,它认为导航已经完成

加载事件在整个网页(HTML)完全加载时触发,包括所有相关资源,如JavaScript文件、CSS文件和图像

在您的情况下,此事件很有可能不会触发一个合理的超时,因此我建议不要依赖此
waitUntil
,而是使用另一个等待,例如,使用某个选择器

await page.goto('https://www.google.com');
await page.waitForSelector('[name="q"]');

据我所知,您不是在解析
google.com
页面。 首先应该考虑的是
waitill:'load'
。它所做的是,当加载事件被触发时,它认为导航已经完成

加载事件在整个网页(HTML)完全加载时触发,包括所有相关资源,如JavaScript文件、CSS文件和图像

在您的情况下,此事件很有可能不会触发一个合理的超时,因此我建议不要依赖此
waitUntil
,而是使用另一个等待,例如,使用某个选择器

await page.goto('https://www.google.com');
await page.waitForSelector('[name="q"]');

谢谢你的回复,我也有同样的问题,页面没有加载你的意思是在你的环境中甚至
wait page.goto('https://www.google.com“)
导航失败,出现超时错误?console.log(“0”)等待页面。转到(“)console.log(“1”)我只能看到console.log(“0”)。我怎么能有日志?你们有什么版本的木偶和chrome?你真的有你在用户代理中指定的旧chrome版本吗?另外,你能说说什么是无头Chrome版本吗?只需
console.log(等待page.browser().version())打开页面之前。有可能是兼容性问题HeadlessChrome/86.0.4240.0感谢您的回复,我也有同样的问题,页面没有加载您的意思是在您的环境中甚至
wait page.goto('https://www.google.com“)
失败,导航?控制台上出现超时错误。日志(“0”)等待页面。转到(“)控制台。日志(“1”)我只能看到console.log(“0”)。我怎么能有日志?你们有什么版本的木偶和chrome?你真的有你在用户代理中指定的旧chrome版本吗?另外,你能说说什么是无头Chrome版本吗?只需
console.log(等待page.browser().version())打开页面之前。这可能是一个兼容性问题HeadlessChrome/86.0.4240.0