打算学习用selenium + phantomJS爬取淘女郎页面照片。

一. 先安装lxml模块

python默认的解析器是html.parser,但lxml解析器更加强大,速度更快

1. 执行 pip install virtualenv

2. 从官方网站下载与系统,Python版本匹配的lxml文件

http://pypi.python.org/pypi/lxml/2.3/

3. 执行 easy_install lxml-2.3-py2.7-win-amd64.egg

二. 安装selenium

pip install selenium

三. 使用selenium写个代码,体验一下,却出现报错

  1. from selenium import webdriver
  2.  
  3. browser = webdriver.Chrome()
  4. browser.get('http://www.baidu.com')

运行一下,出现报错

原因是没有安装chrome浏览器的chromedriver(浏览器驱动),好了直接下载chromedriver.exe,把它放到chrome的安装目录下...\Google\Chrome\Application\ ,并配置环境变量,再次运行,又出现问题了:

原因:这是chrome浏览器版本和chromedriver版本不对应引起的,需要先查看chrome版本(可以在浏览器输入:chrome://help),我的版本是59:

再查看chrome浏览器与chromedriver的对应表,这里这个博客selenium之 chromedriver与chrome版本映射表(更新至v2.31),列出版本映射表:

我的版本59对应的chromedriver的版本是2.3.0或2.3.1,从http://chromedriver.storage.googleapis.com/index.html下载2.3.0,得以成功运行:

注:

可以去官网地址查看每个chromedriver版本对应的chrome浏览器版本:https://sites.google.com/a/chromium.org/chromedriver/downloads

下载地址:https://chromedriver.storage.googleapis.com/index.html

解决:WebDriverException: 'chromedriver' executable needs to be in PATH的更多相关文章

  1. 解决:'chromedriver' executable needs to be in PATH的问题

    0.前言 今天写一个B站登录的模拟器时,用到了Chrome浏览器,但是会报了一个异常"'chromedriver' executable needs to be in PATH", ...

  2. (续篇)Selenium 安装配置以及如何解决('chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/ch)或者(unknown error:cannot find Chrome binary)问题?

    注:本帖针对小小白哦~~(づ ̄3 ̄)づ╭- 接pip安装的帖子,不需要的直接跳过... 首先上图,出现如下的错误,那你可是找到知己了: 或者: 抱歉抱歉,这图截的不太清晰,凑合着用吧,但是也能看出来错 ...

  3. 解决selenium.common.exception.WebDriverException:Message:'chromedriver' executable needs to be in Path

    'chromedriver' executable needs to be in Path 声明:本人萌新,刚学python不久记录一下自己的坑,发出来若能帮助到一些人尽早解决问题那便是极好的,( ̄▽ ...

  4. selenium使用遇到的问题(selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.)

    1.安装pip3 install selenium 2.使用browser=webdriver.Chrome()时报错 :selenium.common.exceptions.WebDriverExc ...

  5. python+selenium,打开浏览器时报selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

    有一年多没写web自动化了,今天搭建环境的时候报了一个常见错误,但是处理过程有点闹心,报错就是常见的找不到驱动<selenium.common.exceptions.WebDriverExcep ...

  6. 关于 'chromedriver' executable needs to be in PATH 的解决办法

    用 chrome 浏览器跑 selenium,执行以下脚本: from selenium import webdriverdr=webdriver.Chrome()dr.maximize_window ...

  7. mac-webui-selenium下的webdriver selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

    from selenium import webdriver def test1(): url='http://www.baidu.com' driver=webdriver.Chrome(" ...

  8. centos7 selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

    1.查看安装的chrome浏览器版本 2.查看版本对应的驱动 https://sites.google.com/a/chromium.org/chromedriver/downloads 下载后拷贝到 ...

  9. Chromedriver executable needs to be in path 解决办法

    执行webdriver.Chrome()时报错:Chromedriver executable needs to be in path. 原因可能是为有安装Chromedriver 可能是Chrome ...

随机推荐

  1. centos6.9下php7安装zip扩展

    cd /usr/local/src wget http://pecl.php.net/get/zip-1.13.5.tgz tar -zxvf zip-1.13.5.tgz cd zip-1.13.5 ...

  2. Python获取位数

    import platform platform.architecture()

  3. Linux中变量测试与内容替换

  4. 修改mysql root的密码

    use mysql:update user set Password = Password('newPwd') where user='root';//更改root用户的密码flush privile ...

  5. self-awareness is key in changing the way you think

    1: controlling the way you think is a manageable process The good news is that you have control over ...

  6. Apache Shiro:【2】与SpringBoot集成完成登录验证

    Apache Shiro:[2]与SpringBoot集成完成登录验证 官方Shiro文档:http://shiro.apache.org/documentation.html Shiro自定义Rea ...

  7. yii2弹出层

    bootstrap http://getbootstrap.com/javascript/#modals https://github.com/lichunqiang/yii2-sweet-submi ...

  8. iOS 给 ViewController 减负 之 UITableView

    今天看了一些博客文章分享了如何给ViewController 瘦身的问题, 其中一个就是tableView. 的确,随着产品迭代,VC里面可能越来越臃肿,有时候真的需要好好进行一次瘦身.可能是参考的博 ...

  9. Linux下运行java项目

    最近初步接触了linux,感觉很有新鲜感.之前在windows下干过的事情也便想到在linux环境下实现一下.正好手头在编java,就想既然java可以在windows的DOS操作下运行,是不是也可以 ...

  10. win32调试——OutputDebugString

    win32下开发console程序可以直接用printf打印到控制台. 开发图形界面程序时,可以调用OutputDebugString将字符串输出到Debug窗口, 注意是要调试运行才能看到Debug ...