Skip to main content
 首页 » 编程设计

networking之如何使用 Selenium 访问谷歌浏览器开发人员工具上的网络面板

2024年12月31日13kerrycode

我想获得开发人员工具的网络面板上显示的输出。

[网络面板-->名称、方法、状态、类型、发起者、大小、时间、时间线]

我需要这些信息。

请您参考如下方法:

使用 Python,一种方法是:

from selenium import webdriver 
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 
import chromedriver_binary # If you're using conda like me. 
 
yoururl = "www.yoururl.com" 
 
caps = DesiredCapabilities.CHROME 
caps['goog:loggingPrefs'] = {'performance': 'ALL'} 
driver = webdriver.Chrome(desired_capabilities=caps) 
 
driver.get(yoururl) 
time.sleep(10) # wait for all the data to arrive.  
perf = driver.get_log('performance') 
 
perf是一个字典列表,您将能够在此列表中找到您要查找的项目。即,字典是您在 Chrome 的开发工具网络选项卡中看到的内容。