【问题标题】:How to read the network requests for a extension in puppeteer如何在 puppeteer 中读取扩展的网络请求
【发布时间】:2018-11-03 08:33:22
【问题描述】:

我正在使用命令启动带有我的扩展的 chrome

google-chrome --remote-debugging-port=9222  --disable-setuid-sandbox --no-sandbox --load-extension=dummyextension --ignore-certificate-errors

通常,当我启用开发人员模式并单击检查视图时,我会看到我的扩展程序发出的所有请求。有没有办法在 puppeteer 的帮助下读取这些网络请求。

我正在尝试读取如下网络请求:

const puppeteer = require('puppeteer');

 (async () => {
   const browser = await puppeteer.connect({browserWSEndpoint :'ws://localhost:9222/devtools/browser/e27e967f-711' });
   const page = await browser.newPage();

   await page.goto('https://github.com');
   await page.setRequestInterception(true);


    page.on('request', request => {
      request.continue(); // pass it through.
    });

    page.on('response', response => {
      const req = response.request();
      console.log( response.status(), req.url());
    });

})();

但我只看到 github 页面的请求,而不是我的扩展程序发出的请求。

【问题讨论】:

    标签: google-chrome google-chrome-devtools puppeteer


    【解决方案1】:

    你试过了吗(来自debugging tips

    # Basic verbose logging
     env DEBUG="puppeteer:*" node script.js
    
     # Debug output can be enabled/disabled by namespace
     env DEBUG="puppeteer:*,-puppeteer:protocol" node script.js # everything BUT protocol messages
     env DEBUG="puppeteer:session" node script.js # protocol session messages (protocol messages to targets)
     env DEBUG="puppeteer:mouse,puppeteer:keyboard" node script.js # only Mouse and Keyboard API calls
    
     # Protocol traffic can be rather noisy. This example filters out all Network domain messages
     env DEBUG="puppeteer:*" env DEBUG_COLORS=true node script.js 2>&1 | grep -v '"Network'
    

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 2021-09-21
      • 2018-08-02
      相关资源
      最近更新 更多