我正在嘗試使用硒打開谷歌。當我運行它時,控制臺中不會出現任何錯誤,但是不會打開 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
提交
取消