如何使pupeteer自动跟随重定向?

时间:2020-02-14 05:19:44

标签: javascript node.js google-chrome google-chrome-headless

我如何使pupeteer自动遵循重定向,就像浏览器处理重定向一样?

例如,如果我尝试在浏览器中加载网站https://www.aonhewitt.com,它将自动重定向到https://www.aon.com/home/solutions/retirement.html。但是,如果我尝试用pupeteer进行以下操作:

const pageResponse = await page.goto(url, {waitUntil: "domcontentloaded"});

出现错误,提示"Navigation timeout of 30000 ms exceeded"。我该如何避免这个错误?

0 个答案:

没有答案