我正在尝试使用硒打开谷歌。当我运行它时,控制台中不会出现任何错误,但是不会打开 chrome 窗口。程序简单地终止。当我在 Chrome 78 上时,我在上一个项目中使用了几乎相同的代码(并且它有效)。它使用的是版本 80。
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common import action_chains, keys
from multiprocessing import Pool, cpu_count, freeze_support
import os
import time
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DRIVER_BIN = os.path.join(PROJECT_ROOT, "chromedriver-80-mac")
def get_driver():
options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(executable_path=DRIVER_BIN, options=options)
return driver
def test():
driver = get_driver()
driver.get('https://www.google.com')
time.sleep(3)
driver.quit()
test()
侃侃无极
RISEBY
随时随地看视频慕课网APP
相关分类