python + selenium 环境搭建

运行环境:windows 7 64位

1 安装python 2.7
下载地址:http://python.org/getit/

2 安装 selenium

如果是联网状态的话,可以直接在***\Python27\Scripts 下输入命令安装: pip install -U selenium       (如果没有安装pip请先安装pip)

3 安装selenium服务端

下载地址:https://www.seleniumhq.org/download/

4 启动selenium 服务端

在selenium-server-standalone-xxx.jar 目录下使用命令java -jarselenium-server-standalone-xxx.jar 启动

5 安装chrome driver

下载地址:https://chromedriver.storage.googleapis.com/index.html?path=2.41/

chrome driver放到chrome 的安装目录下...\Google\Chrome\Application\ 

 调试运行:

# coding = utf-8
from selenium import webdriver
driver =webdriver.Chrome()
driver.get('http://radar.kuaibo.com')
print driver.title
driver.quit()

   ****************************************************************************************************************

可能碰到的问题

1.如下图错误

错误分析:是浏览器版本与driver的版本不匹配导致的

                     谷歌浏览器各版本下载地址:https://dl.lancdn.com/landian/software/chrome/m/

                     selenium之 chromedriver与chrome版本映射表:转自:https://blog.csdn.net/huilan_same/article/details/51896672

猜你喜欢

转载自blog.csdn.net/u010481688/article/details/82113182
今日推荐