当前位置:   article > 正文

配置selenium库的浏览器驱动,解决selenium.common.exceptions.SessionNotCreatedException 报错(保姆级图文)_sessionnotcreatedexception: message: session not c

sessionnotcreatedexception: message: session not created: this version of ch


欢迎关注 『Python』 系列,持续更新中
欢迎关注 『Python』 系列,持续更新中

1.报错分析

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 92
Current browser version is 97.0.4692.71 with binary path C:\Users\ASUS\AppData\Local\Google\Chrome\Application\chrome.exe
  • 1
  • 2
  • SessionNotCreatedException:消息:会话未创建:此版本的ChromeDriver仅支持Chrome版本92
  • 你的电脑默认Chrome浏览器路径是C:\Users\ASUS\AppData\Local\Google\Chrome\Application\chrome.exe
  • 出现这种情况说明你的Chrome浏览器升级了和你的ChromeDriver不兼容

2. 下载适配浏览器版本的ChromeDriver驱动

根据前面报错信息提示的浏览器路径C:\Users\ASUS\AppData\Local\Google\Chrome\Application\chrome.exe找到浏览器,右键属性,再查看得到详细信息中的浏览器版本97.0.4692.71
在这里插入图片描述
依据得到的版本到官方下载网站下载驱动,浏览器ctrl+f搜索

https://npm.taobao.org/mirrors/chromedriver/
  • 1

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


3. 谷歌浏览器本身的问题

正常谷歌浏览器安装在默认路径,如果你是用的什么便携版本第三方魔改的,可能会因为某些组件被绿化掉导致无法正常使用,强烈建议下一个官方的谷歌浏览器一路默认安装下一步(环境变量也会配好,省时省力)


4. 测试是否成功

简单测试用selenium打开博客

# @Time    : 2022/1/15 16:32
# @Author  : 南黎
# @FileName: 测试能否使用selenium.py

from selenium import webdriver

driver = webdriver.Chrome()

driver.maximize_window()

driver.get("https://blog.csdn.net/u011027547")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

在这里插入图片描述
更有趣的测试——
【Python黑科技】免登陆爬取知乎图片(保姆级图文+实现代码)


总结

大家喜欢的话,给个

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/835075
推荐阅读
相关标签