I am trying to intercept network requests using undetected-chromedriver and seleniumwire in Python. Below are my two attempts:
from seleniumwire import webdriver
import undetected_chromedriver as uc
class SeleniumDriver(object):
def __init__(
self,
driver_path='C:\\Users\\ranja\\AppData\\Local\\Google\\Chrome\\User Data',
):
self.driver_path = driver_path
chrome_options = uc.ChromeOptions()
self.driver = uc.Chrome(
executable_path=self.driver_path,
options=chrome_options
)
self.driver.get('https://google.com')
self.start_intercepting_requests()
def start_intercepting_requests(self):
requests = self.driver.requests
print(requests)
I am getting the error: "AttributeError: 'Chrome' object has no attribute 'requests'."
**Attempt 2: **
from selenium import webdriver
import seleniumwire.undetected_chromedriver as uc
class SeleniumDriver(object):
def __init__(
self,
driver_path='C:\\Users\\ranja\\AppData\\Local\\Google\\Chrome\\User Data',
):
self.driver_path = driver_path
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--ignore-certificate-errors')
self.driver = uc.Chrome(
executable_path=self.driver_path,
chrome_options=chrome_options
)
self.driver.get('https://google.com')
self.start_intercepting_requests()
def start_intercepting_requests(self):
requests = self.driver.requests
print(requests)
In Attempt 2, I am encountering a "NET::ERR_CERT_AUTHORITY_INVALID" error. I understand that this is related to SSL certificates, but I'm unsure how to resolve it while still intercepting network requests. Any guidance on how to properly intercept network requests with undetected-chromedriver and seleniumwire, considering the SSL certificate issue, would be appreciated.