简体   繁体   English

如何通过javascript提取Chrome开发者工具的网络标签内容?

[英]How to extract network tab contents of Chrome Developer tools via javascript?

我想提取Chrome开发者工具的网络标签内容,以获取在网页后端运行的网络服务的详细信息。

You can get list of those value via JavaScript: 您可以通过JavaScript获取这些值的列表:

window.performance.getEntries().filter(e=>e.initiatorType==='xmlhttprequest');

The function above returns array of performance entries. 上面的函数返回性能条目数组。 See an example to print the value below. 请参阅示例以在下面打印该值。

<script type="text/javascript">window.performance.getEntries().filter(e=>e.initiatorType==='xmlhttprequest').forEach(entry=>document.write(JSON.stringify(entry) + '<br/>'));</script>

Or you can get an entry from the array: 或者您可以从数组中获得一个条目:

var entry = performance.getEntries().filter(e=>e.initiatorType==='xmlhttprequest')[0];
var name = entry.name;
var startTime = entry.startTime;
var duration = entry.duration;

You can get entries of other types such as 'navigation'. 您可以获取其他类型的条目,例如“导航”。 See entry types from performanceEntryType 查看PerformanceEntryType中的条目类型

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

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