如何访问使用Python在Chrome Devtools网络标签值?

问题描述 投票:1回答:1

有没有从网络访问标签值的方法?喜欢的名称列下例如一切吗?即时通讯使用硒和我有兴趣监测网络选项卡。谢谢

python google-chrome selenium networking devtools
1个回答
1
投票

在C#中我使用方式如下:

初始化驱动程序:

            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;

从日志中获取数据:

var data = driver.Manage().Logs.GetLog("performance");

其结果是 - 你会得到一个巨大的JSON文件量的所有数据。汉译C#这个代码到Python,与解析您需要的JSON数据一起不应该是那么难。希望能帮助到你。

最好的问候,维塔利。

© www.soinside.com 2019 - 2024. All rights reserved.