Forums

Use Selenium WebDriver on PythonAnywhere

I try tu use Selenium WebDriver on PythonAnywhere but keep getting some issues on getting it up and running. I got it working without any problems locally. Here is the (simplified) code that I am having:

from selenium import webdriver
import chromedriver_autoinstaller


chromedriver_autoinstaller.install()  # Check if the current version of chromedriver exists
                                      # and if it doesn't exist, download it automatically,
                                      # then add chromedriver to path



driver = webdriver.Chrome()

I get the error on the line

driver = webdriver.Chrome()

I get the following error:

WARNING:selenium.webdriver.common.selenium_manager:Exception trying to discover chromedriver version: error sending request for url (https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.170/ linux64/chrome-linux64.zip): error trying to connect: unsuccessful tunnel

Anyone any idea what is going on here?

There are a couple of extra things you need to do to get Selenium working on PythonAnywhere, and I don't think that the autoinstaller will work.

There's some sample code on this help page which shows which settings to use with it.

It's worth noting that with a free account, you have restricted Internet access -- you can only access the official public APIs on this list -- so it's likely that many of the sites that you might want to use Selenium to access will not be available.