'Get xhr requests using Selenium-wire and undetected-chromedriver

I'm following the code below, but couldn't get the xhr requests. Code from here. Anyway to fix this?

import seleniumwire.undetected_chromedriver as uc

chrome_options = uc.ChromeOptions()

driver = uc.Chrome(
    options=chrome_options,
    seleniumwire_options={}
)

r = driver.requests

AttributeError: 'Chrome' object has no attribute 'requests'


Solution 1:[1]

You should upgrade selenium-wire to 4.6.1 or above

pip install selenium-wire --upgrade

You can also avoid upgrading with the following code:

from seleniumwire.undetected_chromedriver.v2 import Chrome, ChromeOptions
if __name__ == '__main__':
    chrome_options = ChromeOptions()
    driver = Chrome(options=chrome_options)
    driver.get("https://www.some-anti-bot-site.com")
    r = driver.requests

More info in here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1