我试图使用selenium进行一些抓取,但当我尝试运行此代码时,我得到了以下错误:
我目前正在使用的版本。
Python -- 3.7.13
Selenium -- 4.4.3
webdrivermanager -- 0.10.0
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
错误:
WebDriverException Traceback (most recent call last)
<ipython-input-30-470b559d9ec4> in <module>
2 from selenium import webdriver
3 from webdriver_manager.chrome import ChromeDriverManager
----> 4 driver = webdriver.Chrome(ChromeDriverManager().install())
5 import pandas as pd
6 import time
3 frames
/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
110 raise WebDriverException(
111 'Service %s unexpectedly exited. Status code was: %s'
--> 112 % (self.path, return_code)
113 )
114
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/104.0.5112/chromedriver unexpectedly exited. Status code was: -6
此错误消息。。。
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/104.0.5112/chromedriver unexpectedly exited. Status code was: -6
意味着ChromeDriver无法启动/生成新的浏览上下文,即谷歌chrome
详细信息
_ChromeDriver v104.0.5112.79_的下载路径似乎有一些问题。根据错误消息Selenium正在中搜索ChromeDriver
/root/.wdm/drivers/chromedriver/linux64/104.0.5112/chromedriver
据推测,以下指数为/104.0.5112.79/理想的位置应该是:
/root/.wdm/drivers/chromedriver/linux64/104.0.5112.79/chromedriver
当ChromeDriverManager试图从错误的url下载最新的ChromeDriver时,出现了这个问题。请随时将您的观察结果相加,以帮助我们调试和解决该问题。