Copy multiple network responses in chrome devtools network console

拟墨画扇 提交于 2020-12-13 04:02:50

问题


I want to copy all network responses from the filtered list of requests from the network tab under Chrome's devtools.

I read about the solution of copy all requests' URLs at Multiple URLs copy in Sources/Network tab But I can't figure out how to access the decoded response body from requests.

The solution at Chrome Devtools: Save specific requests in Network Tab works, but I want a solution that only extracts responses from the filtered request list under the network tab.


回答1:


Inspecting the source code of devtools reveals we need contentData() method.

The how-to-use instructions are the same as in Multiple URLs copy in Sources/Network tab.

(async () => {
  const getContent = r => r._url && !r._url.startsWith('data:') && r.contentData();
  const nodes = UI.panels.network._networkLogView._dataGrid._rootNode._flatNodes;
  const requests = nodes.map(n => n._request);
  const bowels = await Promise.all(requests.map(getContent));
  const looks = bowels.map((data, i) => {
    const r = requests[i];
    const url = r._url;
    const content = !data ? 'data is encoded inside the data url already, duh' :
      r.contentType().isTextType() ? data.content :
        Common.ContentProvider.contentAsDataURL(data.content, r.mimeType, data.encoded);
    return {url, content};
  });
  console.log(looks);
})();


来源:https://stackoverflow.com/questions/57764902/copy-multiple-network-responses-in-chrome-devtools-network-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!