• 关于python-selenium-chromedriver提示


    问题一: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_studypythonpython_study_listvenvScriptspython.exe E:code_studypythonpython_study_list网络爬虫学习study_selenium_1.py
    Traceback (most recent call last):
      File "E:code_studypythonpython_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文件。

  • 相关阅读:
    Http请求头和相应头分析
    linux扩充容量经典篇
    Redis持久化以及其原理
    redis简单应用
    Python Requests库使用2:请求方法
    加快访问GitHub的速度
    GET和POST两种基本请求方法的区别
    Python Requests库介绍
    Python urllib、urllib2、urllib3用法及区别
    Django中操作cookie和session
  • 原文地址:https://www.cnblogs.com/wyf-349/p/11369465.html
Copyright © 2020-2023  润新知