我正在尝试使用硒打开谷歌。当我运行它时,控制台中不会出现任何错误,但是不会打开 chrome 窗口。程序简单地终止。当我在 Chrome 78 上时,我在上一个项目中使用了几乎相同的代码(并且它有效)。它使用的是版本 80。from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common import action_chains, keysfrom multiprocessing import Pool, cpu_count, freeze_supportimport osimport timePROJECT_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 driverdef test(): driver = get_driver() driver.get('https://www.google.com') time.sleep(3) driver.quit()test()
添加回答
举报
0/150
提交
取消
