Shadow
Shadow

Reputation: 1

Proxy not connecting in selenium in chrome driver

i was building a code to do something in selenium i have to connect to proxy to make it work i have some resendetial proxies but when i tried them on selenium it shows an error i have tried various drivers too

i have used the following codes:

proxy_url = f"{proxy_username}:{proxy_password}@{proxy_address}:{proxy_port}"
options = Options()
options.add_argument('--proxy-server=http://%s' % proxy_url)
driver = webdriver.Chrome(options=options)
driver.get('https://idk.me')
print(driver.page_source)
time.sleep(50)
driver.quit()

when using this i get:"This site can’t be reached The web page at https://idk.me might be temporarily down or it may have moved permanently to a new web address. ERR_NO_SUPPORTED_PROXIES i also tried with firefox but the user and pass authentication keeped popping up

Upvotes: 0

Views: 2208

Answers (1)

Michael Mintz
Michael Mintz

Reputation: 15556

If you want to use Selenium with a proxy server that has authentication, you'll need to create a Chromium extension with the correct configuration, which is detailed here: https://stackoverflow.com/a/35293284/7058266

Alternatively, you can use selenium-wire to run Selenium on a proxy server that has authentication, which is detailed here: https://stackoverflow.com/a/56276796/7058266

Another way is to run a SeleniumBase test with a command-line option that specifies a proxy server with authentication:

pytest --proxy=USERNAME:PASSWORD@IP_ADDRESS:PORT

(That option does the work of creating the Chromium extension for you.)

Upvotes: 2

Related Questions