Python 如何像在colab中一样在jupyter笔记本中运行selenium
我正在python协作中使用selenium。但我需要在笔记本中使用相同的代码(我无法下载chromedriver)。 代码如下:Python 如何像在colab中一样在jupyter笔记本中运行selenium,python,selenium,selenium-webdriver,jupyter-notebook,Python,Selenium,Selenium Webdriver,Jupyter Notebook,我正在python协作中使用selenium。但我需要在笔记本中使用相同的代码(我无法下载chromedriver)。 代码如下: !pip install webdriver-manager !apt update !apt install chromium-chromedriver !pip install selenium options = webdriver.ChromeOptions() options.add_argument('--headless') options.add_a
!pip install webdriver-manager
!apt update
!apt install chromium-chromedriver
!pip install selenium
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
driver = webdriver.Chrome(options=options)
driver.get("https:....")
我原以为这段代码可以在noteboot中运行,但当我在笔记本中运行时,这会给我带来错误
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
是否可以在笔记本中运行此类代码?可以。您看到的错误与jupyter无关-它只是告诉您尚未配置chromedriver的路径。请看:我不能下载chromedriver,这就是为什么我需要一些没有下载chromedriver就可以工作的东西,比如在Colab为什么你不能下载chromedriver?尝试安装时是否出错?在我要运行脚本的计算机中,它被拒绝。