首页 技术 正文
技术 2022年11月19日
0 收藏 542 点赞 2,942 浏览 947 个字

打算学习用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

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

二. 安装selenium

pip install selenium

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

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

运行一下,出现报错

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

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

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

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

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

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

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

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

解决:WebDriverException: 'chromedriver' executable needs to be in PATH

注:

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

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297