Skip to content

Instantly share code, notes, and snippets.

@jgs03177
Created April 5, 2024 15:13
Show Gist options
  • Save jgs03177/d75a1f020271cebb867124f7712df487 to your computer and use it in GitHub Desktop.
Save jgs03177/d75a1f020271cebb867124f7712df487 to your computer and use it in GitHub Desktop.
http request analysis with selenium, without fiddler
# request analysis with selenium, without fiddler
# references:
# https://stackoverflow.com/a/63732179
# https://stackoverflow.com/a/27644635
# https://stackoverflow.com/a/69931030
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import json
options = webdriver.ChromeOptions()
options.set_capability("goog:loggingPrefs", {'performance': 'ALL'})
target_link = "https://google.com"
driver = webdriver.Chrome(options=options)
driver.get(target_link)
logs = driver.get_log('performance') # dump perf logs
for entry in logs:
msg = json.loads(entry['message'])['message']
if msg['method']=="Network.requestWillBeSent":
print(msg)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment