首页 > 解决方案 > Selenium Python 在 Google Colab 中不起作用

问题描述

我在 google colab 上使用了以下代码并安装了 selenium 包

# !pip install selenium
# !apt-get update # to update ubuntu to correctly run apt install
# !apt install chromium-chromedriver
# !cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
wd.get("https://pooya.um.ac.ir/gateway/PuyaAuthenticate.php")

只是加载了一段时间,根本不工作..!! 我怎样才能修复它以访问任何网站?

标签: pythonseleniumselenium-webdrivergoogle-colaboratory

解决方案


推荐阅读