Hiiiii,
我想抓一個文本從簡單的web頁麵代碼:
從硒進口webdriver #選項設置為簡化瀏覽#函數負責創建一個司機和返回驅動程序。def get_driver (): chrome_options = webdriver.ChromeOptions () chrome_options.add_argument (start-maximized) chrome_options.add_argument chrome_options.add_argument (“disable-infobars”) (“disable-dev-shm-usage”) chrome_options.add_argument chrome_options (“no-sandbox”)。add_experimental_option (“excludeSwitches”,["實現自動化"])chrome_options.add_argument (“disable-blink-features = AutomationControlled”)司機= webdriver。Chrome(選項= chrome_options) #驅動程序連接到一個web頁麵driver.get (“http://automated.pythonanywhere.com”) #返回驅動程序為這個特定的web頁麵返回司機def主要():司機= get_driver =()元素的司機。find_element (=“xpath value = " / html /身體/ div [1] / div / h1[1] ")返回元素。文本打印(main ())
錯誤消息:
WebDriverException:消息:未知錯誤:Chrome未能開始:退出異常。(未知錯誤:DevToolsActivePort文件不存在)(這個過程開始從chrome位置/root/.cache/selenium/chrome/linux64/115.0.5790.170 /鉻不再運行,所以ChromeDriver假設chrome已經崩潰。)加:# 0 0 x55e176cd1613 # 1 0 x55e1769fd537 x55e176a28588 # 3 # 2 0 0 0 x55e176a65643 x55e176a255d9 # 4 # 5 0 x55e176a64d8f x55e176a5c803 # 7 # 6 0 0 0 x55e176a3142e x55e176a3068b # 8 # 9 0 x55e176c92c28 # 10 0 0 x55e176ca101c x55e176c96af7 # 11 # 12 0 x55e176c97723 # 0 x55e176c66457 13 # 14 # 15 0 0 x55e176cbb628 x55e176cbb7b7 16 0 x55e176cca483 # 17 # 0 x7efedfacc609 start_thread - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WebDriverException回溯(最近調用最後)<命令- 1651202861729537 > <細胞係:6 >()4返回元素。文本5 - - - - - > 6打印(main())主要()1 - 1651202861729537 > <命令def主要():- - - - - > 2司機= get_driver() 3元素=司機。find_element (=“xpath value = " / html /身體/ div [1] / div / h1[1]”) 4返回元素。文本5 - 1651202861729536 > <命令get_driver () = webdriver 12 13 - - - > 14司機。鉻(選項=選項)15 16 #驅動程序連接到一個web頁麵
你能解釋這個錯誤是什麼意思,我怎麼能解決嗎?