0

First of all I need to track requests, because some sites which I need to process are hiding their real domain by immediately redirecting to fake domain. To accomplish that I've chosen selenium-wire (if there are better options to do that please let me know) and I'm using it in pair with with undetected_chromedriver. Those two alone are working fine. However from time to time I need to change my IP. To do that I'm using Windscribe's Chrome extension and now all the problems begins, because after connection to Windscribe selenium-wire is immediatly stopping to track requests.

My selenium-wire with undetected_chromedriver driver setup:

options = uc.ChromeOptions()

# use profile with windscribe installed
options.add_argument(r'--user-data-dir=C:\Users\user_name\AppData\Local\Google\Chrome\User Data 01')
options.add_argument('--profile-directory=Profile 1')

# sets windows position depend on setup; window_setup[0] = window position, window_setup[1] = window size
options.add_argument(config['window_setup'][0])
options.add_argument(config['window_setup'][1])
options.set_capability("detach", True)
seleniumwire_options = {
    'request_storage_base_dir': config['request_storage_base_dir']
}

# lunch webdriver
driver = uc.Chrome(options=options, use_subprocess=True, seleniumwire_options=seleniumwire_options)

# clear cache and cookies
driver.get(r'chrome://settings/clearBrowserData')
time.sleep(2)
clear_button = driver.execute_script(
    "return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.\
    querySelector('settings-basic-page').shadowRoot.querySelector('settings-section > settings-privacy-page').\
    shadowRoot.querySelector('settings-clear-browsing-data-dialog').shadowRoot.querySelector\
    ('#clearBrowsingDataDialog').querySelector('#clearBrowsingDataConfirm')")
# click on the clear button now
clear_button.click()
time.sleep(2)
print('~Driver initialized')

I've tried to look for a solution alone, but didn't find any informations about using selenium-wire with Windscribe. Any help will be appreciated. If anyone knows better way for tracking urls changes please let me now.

Thanks in advance!

KacMaz
  • 1
  • There actually should be a way, but it's quite complicated and I don't really have time for developing. You can use [cdp_events](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-enable) [selenium-interceptor](https://github.com/kaliiiiiiiiii/Selenium-Interceptor) to get the desired url. And then use a residential proxy, for example form asocks or other providers. – kaliiiiiiiii Mar 03 '23 at 18:51

0 Answers0