I'm tring to add a proxy to chrome driver with BrightData, Selenium and Python, but for some reason doesn't works well. I have to add user and password too. The driver works fine, but when I see my ip from the driver, shows me my ip public, not proxy ip.
PROXY_HOST = 'xxxx'
PROXY_PORT = 'xxxx'
PROXY_USER = 'xxxx'
PROXY_PASS = 'xxxx'
PROXY = PROXY_HOST+':'+PROXY_PASS+'@'+PROXY_USER+':'+PROXY_PORT
options = Options()
options.headless = headless_mode
options.add_argument("--window-size=1920,1200")
options.add_experimental_option("excludeSwitches", ["enable-logging"])
options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(options = options, executable_path = DRIVER_PATH)
driver.get('https://www.cual-es-mi-ip.net/')
Finally, I have changed the import from selenium.webdriver.chrome.options
by the parameter in driver seleniumwire_options
:
PROXY = PROXY_HOST + ':' + PROXY_PASS + '@' + PROXY_USER + ':' + PROXY_PORT
options = {
'proxy': {
'http': 'http://' + PROXY,
'https': 'https://' + PROXY
}
}
driver = webdriver.Chrome(
seleniumwire_options=options,
executable_path=DRIVER_PATH
)
driver.get('https://url-example.com')