Rom*_*man 7 javascript node.js google-chrome-headless puppeteer
我有一个 puppeteer 项目,需要提交一个表单,然后等待下一页。问题是要进入下一个页面,站点会进行大约 3-4 次重定向,然后才会开始加载实际内容。
看来 Puppeteer 被卡在了中间的某个地方。
我将如何解决这个问题?
这是我的代码:
await page.goto('<url>/Login.html', {'waitUntil': 'networkidle0', timeout: 60000});
await page.click(USERID_SLCT);
await page.keyboard.type(creds.userId);
await page.click(PWD_SLCT);
await page.keyboard.type(creds.pwd);
await page.click(LOGINBTN_SLCT);
await page.waitForNavigation({'waitUntil': 'networkidle0'});
await timeout(240000); // wait for the redirects to be finished
await page.waitForSelector(BTN_SLCT, {timeout: 240000}); // make sure the page is loaded <-- would fail here
await page.screenshot({path: './screenshots/mainpage.png'});
Run Code Online (Sandbox Code Playgroud)
ily*_*lya 14
我遇到了类似的问题,并通过等待所需页面中的特定选择器来解决它。
await page.waitForSelector('#manage-trips', { visible: true, timeout: 0 });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12177 次 |
| 最近记录: |