Console.log拦截响应/请求

时间:2019-03-05 09:10:41

标签: javascript websocket chromium puppeteer

我想console.log()用WebSocket制作的requestresponse

const browser = await puppeteer.launch({
  headless: false,
  args: [
    '--incognito',
    '--enable-features=NetworkService'
  ]
});
...
await page.on('console', msg => {
    console.log(msg);
  }
});
...
await page.setRequestInterception(true);
  page.on('request', request => {
    console.log('Intercepting Request ', request, { depth: null });
    request.continue();
  });

  page.on('response', response => {
    console.log('Intercepting Response ', response, { depth: null });
  });

尽管已创建request,但它不记录response。它也不会记录 page.on('response', response => { console.log('Intercepting Response ', response, { depth: null }); response.continue(); }); 。但是,当我添加

response

向它记录class BasicLayoutActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_basic_layout) setSupportActionBar(toolbar) } override fun onCreateOptionsMenu(menu: Menu?): Boolean { super.onCreateOptionsMenu(menu) menuInflater.inflate(R.menu.menu_basic_layout,menu) return true } } 。但后来我得到

  

(节点:15634)UnhandledPromiseRejectionWarning:TypeError:response.continue不是函数

这是怎么回事?

0 个答案:

没有答案