mac os+selenium2+chrome驱动+python3

mac os 10.11.5 
mac自带python2.7,自己下载了python3.5,pip list查看系统中的安装包,本人电脑中已经安装了pip和setuptools,若未安装,请先使用

sudo apt-get install python3-setuptools
  • 1
  • 1
sudo apt-get install python3-pip
  • 1
  • 1

若使用命令有问题,可自行到官网下载相应安装包,执行Python setup.py install 安装即可;

1、安装selenium

执行 python3 -m pip install selenium

2、安装chrome驱动

驱动下载地址:http://docs.seleniumhq.org/download/选择对应系统的浏览器驱动 
这里写图片描述
或者直接到 
https://sites.google.com/a/chromium.org/chromedriver/下载最新版mac chrome驱动(需FQ); 
这里写图片描述
这里写图片描述
我下载了mac64.zip和linux64.zip,共享地址:

链接: https://pan.baidu.com/s/1nvdKv7F 密码: uc2i

使用uname -a查看自己的系统是64位还是32位;

3、配置chrome驱动

将解压后的chromedriver移动到/usr/local/bin目录下 
否则在运行脚本时,会提示 
chromedriver executable needs to be in PATH错误 
这里写图片描述

4、selenium第一个脚本

编写第一个selenium脚本程序:

#!/user/bin/env python
# -*-coding:utf-8-*-
# @time       : 16/11/8 12:09
# @Author     : Zhangxy
# @File       : 001baiduSearch.py
# @Software   : PyCharm

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()
#driver.quit()
posted @ 2017-06-26 22:17  xqnq2007  阅读(282)  评论(0编辑  收藏  举报