首页 > 解决方案 > requestfailed.failure() 为阻止的混合内容错误给出 null

问题描述

对于块内容事件,会触发“请求失败”事件。但是对于这个特定事件, requestfailed.failure() 给出的是空值而不是错误文本。有没有人有解决方法?

重现步骤:

  1. 使用 puppeteer,导航到有任何混合内容错误的页面。例如 https://books.toscrape.com/catalogue/category/books/add-a-comment_18/index.html 在此处输入图像描述

  2. 我有以下监听器用于监听请求失败事件

    page.on('requestfailed', requestfailed => {
      var req=JSON.stringify(requestfailed.failure())   
      console.log('requestfailed occurred: ', req);
    })
    
  3. 对于上面的 URL,它的返回值为 null

在此处输入图像描述

环境:

Puppeteer version:^5.5.0
Platform / OS version: Windows 7
Node.js version:v12.18.4

PS:在 github https://github.com/puppeteer/puppeteer/issues/7036上为 puppeteer 社区创建了一张票

标签: node.jspuppeteer

解决方案


推荐阅读