[英]How to access values in the Chrome Devtools network tab using Python?
Is there a way to access values from the Network tab?有没有办法从“网络”选项卡访问值? Like for example everything under the Name column?
例如,名称列下的所有内容? Im using Selenium and am interested in monitoring the Network tab.
我正在使用 Selenium,并且对监控“网络”选项卡感兴趣。 Thanks
谢谢
In C# I'm using the following way:在 C# 中,我使用以下方式:
Initializing driver:初始化驱动:
var perfLogPrefs = new ChromePerformanceLoggingPreferences();
perfLogPrefs.AddTracingCategories(new string[] { "devtools.network", "devtools.timeline" });
options.PerformanceLoggingPreferences = perfLogPrefs;
options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true);
options.SetLoggingPreference("performance", LogLevel.All);
driver = new ChromeDriver(
ConfigManager.ChromeDriverPath, options);
ScenarioDefinitions.PathToGoogleCustomProfile = string.Empty;
Getting data from the logs:从日志中获取数据:
var data = driver.Manage().Logs.GetLog("performance");
As a result - you would get a huge amount of json files with all the data.结果 - 您将获得包含所有数据的大量 json 文件。 Translating this code from C# to Python, along with parsing the data you need from json shouldn't be that hard.
将此代码从 C# 转换为 Python,以及从 json 解析您需要的数据不应该那么难。 Hope it helps.
希望能帮助到你。
Best Regards, Vitali.最好的问候,维塔利。
I did it in Python using Selenium我使用 Selenium 在 Python 中做到了
https://stackoverflow.com/a/68363046/8491363 https://stackoverflow.com/a/68363046/8491363
The key is setting the performance log.关键是设置性能日志。
From Selenium 4.0 onward, the library officially support accessing Chrome devtool info so you can also use that instead.从 Selenium 4.0 开始,该库正式支持访问 Chrome 开发工具信息,因此您也可以使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.