I can't connect using proxies using Selenium Chrome WebDriver on Python 3.7
1 - When using a proxy (adding -proxy-server=%s on chrome_options)
def selenium_connect():
PROXY = "66.97.38.58:80"
url = "http://whatsmyip.org"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(url)
In this case I get an empty result.
2 - I have tried this alternative: How do you run headless chrome and a proxy using selenium in python?
def selenium_connect():
PROXY = "66.97.38.58:80"
url = "http://whatsmyip.org"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
desired_caps = chrome_options.to_capabilities()
prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.http_proxy = PROXY
prox.add_to_capabilities(desired_caps)
driver = webdriver.Chrome(chrome_options=chrome_options, desired_capabilities=desired_caps)
driver.get(url)
I this case, the connection is routed via my local ip and not the proxy's ip. I've uploaded the function in docker here:
https://github.com/gerimo/challenge
I'm using a standard ubuntu Docker environment, selenium-3.141.0, chromium-chromedriver 68.0
http://whatsmyip.org?