joyzoursky / docker-python-chromedriver

Dockerfile for running Python Selenium in headless Chrome (Python 2.7 / 3.6 / 3.7 / 3.8 / Alpine based Python / Chromedriver / Selenium / Xvfb included in different versions)
https://hub.docker.com/r/joyzoursky/python-chromedriver/
MIT License
638 stars 196 forks source link

Using Proxies #9

Closed gerimo closed 3 years ago

gerimo commented 5 years ago

Hi Joy! Why do you think I can't connect using proxies?

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)

Been struggling with these and can't seem to find a way.

joyzoursky commented 5 years ago

Not so sure, I haven't tried with proxy too. Have you tried chrome_options.add_argument('--proxy-server=http://%s' % PROXY)? Seems the http:// is necessary.