• 【Python 解决错误】selenium.common.exception.WebDriverException


    近来准备写个脚本去搜索某端游的官网交易平台。因为也不懂高端的爬虫技术,决定用selenium去戳。这里采用的是chrome浏览器,链接网页时报错:

    File "C:Python37libsite-packagesseleniumwebdriverchromewebdriver.py", line 73, in __init__
    self.service.start()
    File "C:Python37libsite-packagesseleniumwebdrivercommonservice.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
    selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

    解决办法:

    安装与浏览器版本匹配的webdriver

    1、打开谷歌浏览器, 在地址栏输入 chrome://version/  查看版本信息,我的版本信息描述如下:

    Google Chrome 72.0.3626.119 (正式版本) (32 位) (cohort: Stable)
    修订版本 9a65993e2cde1b5797ec98da4cd9abcea464cd7b-refs/branch-heads/3626@{#876}
    操作系统 Windows

    2、选择合适版本的驱动下载, 如果没有完全匹配的就选最相似匹配的版本下载。(比如我的版本没有完全匹配的,我选了一个临近的驱动,也可用)

    下载地址:

    http://chromedriver.storage.googleapis.com/index.html

    3、解压下载的驱动放到指定目录,代码调用时指定该目录即可。

    我把它放在了selenium下的chrome了,代码演示如下

    from selenium import webdriver

    chrome_driver = r"C:Python37Libsite-packagesseleniumwebdriverchromechromedriver.exe"
    browser = webdriver.Chrome(executable_path=chrome_driver)

    成功解决问题!

  • 相关阅读:
    PHP -----上传文件
    PHP----预定义数组
    PHP-------- 会话控制
    PHP------XML
    PHP----练习-----三级联动
    PHP-------ajax返回值 返回JSON 数据
    PHP----练习----光标离开文本框时变色
    使用ansible安装配置zabbix客户端
    svn+apache安装配置
    rsync+lsyncd实现实时同步
  • 原文地址:https://www.cnblogs.com/yao-zhang/p/10449033.html
Copyright © 2020-2023  润新知