问题描述
爬虫时遇到调用chrome报错问题:
Message: unknown error: cannot find dict ‘desiredCapabilities’
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find dict 'desiredCapabilities'
原因分析:
1.chromedriver.exe版本过低
2.指向路径错误
首先找到chrome根目录右键属性查看浏览器的版本

在 官网 找到相似的版本下载

找到对应文件下载(ps:64位系统也可以使用win32)

将解压之后的文件放在和浏览器相同的位置

再使用binary_location方法把浏览器以及chromedriver.exe文件的绝对路径添加上去运行即可
>option = webdriver.ChromeOptions()
option.add_argument(handle) # 设置option,后台运行
option.binary_location=r'C:\Program Files\Google\Chrome\Application\chrome.exe'
driver = webdriver.Chrome(r'C:\Program Files\Google\Chrome\Application\chromedriver.exe')
driver.get(target)
3450

被折叠的 条评论
为什么被折叠?



