pythonselenium-webdriverselenium-chromedriverhttp-proxy

How to load https web site with proxy in Selenium


I am using chrome and selenium in python. I have a code for using proxy in chrome it work but only for http web site (I think) and it doesn't load https(ssl).

I tried this code

from selenium import webdriver
http_proxy = "http://118.69.134.2:80"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f'--proxy-server={http_proxy}')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://httpbin.org/ip")
print(driver.find_element(By.TAG_NAME, "body").text)
driver.quit()

It fails with ERR_TIMED_OUT


Solution

  • We can try to add extensions to webdriver to achieve the purpose of using the proxy, provided that your proxy is working properly, please check: gist