全部
我使用 puppeteersharp ,需要拦截请求和响应,当使用打击代码时:
page.Response += OnPageResponse,
当 url 为 Navigation 时,无法获取内容,错误:
Unable to get response body ---> PuppeteerSharp.MessageException: Protocol error (Network.getResponseBody): No resource with given identifier found
报错链接:https ://github.com/puppeteer/puppeteer/issues/2258
该链接gvie围绕该错误的文章:Using Chrome Devtools Protocol with Puppeteer https://medium.com/@jsoverson/using-chrome-devtools-protocol-with-puppeteer-737a1300bac0
但是将 Chrome Devtools 协议与 PuppeteerSharp 一起使用,我遇到了错误:
Invalid parameters patterns: array expected
设置参数时:
object oo = new { urlPattern = "*", resourceType = "Script", interceptionStage = "HeadersReceived" };
object arg = "{ patterns: [{urlPattern: '*.js*',resourceType: 'Script',interceptionStage: 'HeadersReceived'}] }";
arg = "{ patterns: [{urlPattern='*.js*',resourceType='Script',interceptionStage='HeadersReceived'}] }";
arg = "{ patterns: [{urlPattern=\"*.js*\",resourceType=\"Script\",interceptionStage=\"HeadersReceived\"}] }";
arg = "{ patterns: [{urlPattern:\"*.js*\",resourceType:\"Script\",interceptionStage:\"HeadersReceived\"}] }";
arg = "[{urlPattern:\"*.js*\",resourceType:\"Script\",interceptionStage:\"HeadersReceived\"}]";
arg = "[{urlPattern=\"*.js*\",resourceType=\"Script\",interceptionStage=\"HeadersReceived\"}]";
Console.WriteLine("arg:" + arg);
tjj = cdp.SendAsync("Network.setRequestInterception", arg);
以上是我测试的所有格式,都是错误的,那么arg格式是什么?
谢谢。