Get xhr requests using Selenium-wire and undetected-chromedriver

Viewed 1646

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'
1 Answers

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

Related