【问题标题】:How to run chrome webdriver in google colab?如何在谷歌 colab 中运行 chrome webdriver?
【发布时间】:2021-08-12 13:37:00
【问题描述】:

如何在google colab中运行chrome webdriver?

点安装

  1. !pip install selenium
  2. !apt-get 更新
  3. !apt install chromium-chromedriver
  4. !cp /usr/lib/chromium-browser/chromedriver /usr/bin

my sample code

from selenium import webdriver 

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver', options=options)
url = "https://www.instagram.com/" 

driver.get(url)

我的照片

当我在 colab 中运行 chrome webdriver 时,

I want to see the execution process with a window.

但是窗口打不开。

我该如何处理?

更新帖子

更新 post2

【问题讨论】:

    标签: selenium


    【解决方案1】:

    要查看浏览器打开等情况,您应该以常规模式运行浏览器,而当前您正在以无头模式运行。
    所以,你不必使用options.add_argument('--headless')

    【讨论】:

    • Except options.add_argument('--headless') an error occurs.我该怎么办?
    • 发布更新成功。如果您能看到错误,我将不胜感激。
    • 我不确定,但我会删除所有其他 options 并尝试使用默认配置文件设置运行驱动程序
    • @Prophet我尝试了除了选项,但仍然有错误。发布更新成功。
    • 嗯...说实话:我已经好几年没有在 Python 中使用 selenium 了,所以我不知道。这些天我的电脑上什至没有 Python...
    猜你喜欢
    • 1970-01-01
    • 2022-11-20
    • 2019-03-02
    • 2020-05-07
    • 2019-11-14
    • 2020-01-27
    • 2020-02-02
    • 2020-10-04
    • 1970-01-01
    相关资源
    最近更新 更多