Puppeteer Page.Evaluate未能到达网站

发布于 2025-02-12 20:12:32 字数 389 浏览 0 评论 0原文

我的长期加载网页有问题,该网页被部分求解在这里。 如果我尝试重新加载页面,然后

await page.evaluate(() => {
   location.reload(true);
});

再次陷入困境。似乎什么都不是我使用Page.Evaluate在此加载状态时浏览浏览器。在代码被卡住时,请在无头模式下手动刷新= false。 如何刷新网站或以某种方式使Page.espaine再次使用?

编辑:单击下一页按钮后,该网站加载了很长时间。它并不总是发生,而是几次。

I had a problem with a long-time loading webpage that is partially solved here.
If I try to reload the page with

await page.evaluate(() => {
   location.reload(true);
});

It is stuck again. It seems like nothing that I'd do with page.evaluate goes through to the browser while it is in this loading state. Manually refreshing in headless mode=false with location.reload(true) while the code is stuck works.
How can I refresh the website or somehow make page.evaluate usable again?

Edit: The website loads for a long time after a click on a next page button. It does not always happen, but only a very few times.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安静被遗忘 2025-02-19 20:12:32

不建议这样做,如果是在超时后重新加载,您可以

try {
      await page.goto(url, {timeout: 10000});
} catch (e) {
      console.log("time out , reload!");
      await page.reload(url);
      await page.evaluate(() => {
         ......
      });
}

This is not recommended, if it is to reload after a timeout, you can

try {
      await page.goto(url, {timeout: 10000});
} catch (e) {
      console.log("time out , reload!");
      await page.reload(url);
      await page.evaluate(() => {
         ......
      });
}
心碎无痕… 2025-02-19 20:12:32

只是为了确保对此进行测试。

    await page.evaluate(() => {
       window.location.reload(true);
    });

或者

   await page.evaluate(() => {
       document.location.reload(true);
    });

just to make sure test this.

    await page.evaluate(() => {
       window.location.reload(true);
    });

or

   await page.evaluate(() => {
       document.location.reload(true);
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文