在chrome devtools网络控制台中复制多个网络响应 [英] Copy multiple network responses in chrome devtools network console
问题描述
我想从Chrome的devtools下的网络"标签中的过滤出的请求列表中复制所有网络响应.
I want to copy all network responses from the filtered list of requests from the network tab under Chrome's devtools.
我在在来源/网络"标签中复制多个URL 但是我不知道如何从请求中访问解码后的响应主体.
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.
推荐答案
Inspecting the source code of devtools reveals we need contentData() method.
使用方法说明与在源/网络"标签中复制多个URL 相同.
(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);
})();
这篇关于在chrome devtools网络控制台中复制多个网络响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!