码迷,mamicode.com
首页 > 编程语言 > 详细

关于python-selenium-chromedriver提示

时间:2019-08-17 17:41:08      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:most   web   代码   注意   baidu   webdriver   cut   mos   pytho   

问题一:AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chromedriver‘

配置selenium环境时,执行代码

from selenium import webdriver
driver = webdriver.Chromedriver() #driver = webdriver.Chromedriver(executable_path=‘C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe‘) driver.get(‘http:\\www.baidu.com‘)

提示如下报错

E:\code_study\python\python_study_list\venv\Scripts\python.exe E:\code_study\python\python_study_list\网络爬虫学习\study_selenium_1.py
Traceback (most recent call last):
  File "E:\code_study\python\python_study_list\网络爬虫学习\study_selenium_1.py", line 5, in <module>
    driver = webdriver.Chromedriver()
AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chromedriver‘

Process finished with exit code 1

 后来发现:

  将如下代码:

driver = webdriver.Chromedriver()

  替换为:

driver = webdriver.Chrome()

  即可。

  还需要注意的是,工作目录下不要存在与库相关的同名文件,建议修改。

问题二: 谷歌浏览器与chromedriver.exe不匹配的问题

  网上有对应的版本和chromedriver的对应关系,需要说明的是,你下载的最新版本的谷歌(比如我下的77版本),其实际安装的版本是76版本。所以需要下载对应76的版本chromedriver.exe文件。

关于python-selenium-chromedriver提示

标签:most   web   代码   注意   baidu   webdriver   cut   mos   pytho   

原文地址:https://www.cnblogs.com/wyf-349/p/11369465.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!