繁体   English   中英

使用pupeteer拦截和模拟WebSockets请求/响应

[英]Intercept and mock WebSockets request/responses with pupeteer

有没有办法用p来拦截和模拟WebSockets请求/响应?

  page.on('request', request => {
    console.log('Intercepting Request ', request, { depth: null });
    request.continue();
  });

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

不显示通过WebSocket进行的请求/响应。 如何使用puppeteer来转储WebSocket数据在某种程度上回答了这个问题,但不是通过使用puppeteer而是通过ws

您是否设置了请求拦截?

   await page.setRequestInterception(true)
   page.on('request', interceptedRequest => {
     interceptedRequest.continue()
   })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM