python get website chrome network tab

Solutions on MaxInterview for python get website chrome network tab by the best coders in the world

showing results for - "python get website chrome network tab"
Lohan
26 Jul 2019
1from selenium import webdriver
2from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
3from selenium.webdriver.chrome.options import Options
4
5def get_perf_log_on_load(self, url, headless = True, filter = None):
6
7    # init Chrome driver (Selenium)
8    options = Options()
9    options.headless = headless
10    cap = DesiredCapabilities.CHROME
11    cap['loggingPrefs'] = {'performance': 'ALL'}
12    driver = webdriver.Chrome(desired_capabilities = cap, options = options)
13
14    # record and parse performance log
15    driver.get(url)
16    if filter: log = [item for item in driver.get_log('performance')
17                      if filter in str(item)]
18    else: log = driver.get_log('performance')
19    driver.close()
20
21    return log