简体   繁体   中英

Selenium Proxy with Bright Data chrome driver

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'.

 text_to_search = 'https://url-exemple.com'
        
 PROXY = PROXY_HOST+':'+PROXY_PASS+'@'+PROXY_USER+':'+PROXY_PORT
        
  options = {
     'proxy': {'https': 'http://'+PROXY,
     'https': 'https://'+PROXY},
 }

 driver = webdriver.Chrome(seleniumwire_options = options, executable_path = DRIVER_PATH)
 driver.get(text_to_search)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM