Python+Selenium 从零开始安装

  1. Python3 安装,安装路径$(PyInstallPath)
  2. selenium安装:pip install selenium
  3. webdriver 安装:pip install webdriver
  4. 添加环境变量:$(PyInstallPath);$(PyInstallPath)\Scripts
  5. 下载Chrome浏览器,不要下载极速版本,使用过程会出现各种怪异的问题
  6. 下载Chrome驱动ChromeDriver.exe:http://chromedriver.storage.googleapis.com/index.html
    6.1 下载版本与浏览器版本一致;
    6.2 解压ChromeDriver后复制ChromeDriver.exe文件到$(PyInstallPath)\Scripts目录下;

测试环境安装情况:
Python:cmd ,输入python,出现 >>>,说明python已安装好
ChromeDriver:打开python ide,逐条输入以下代码回车,没报错且可打开Chrome浏览器且打开百度,说明都安装好了,看正常使用
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')

解决办法:

  1. 浏览器安装稳定版本,不要极速版;
  2. 浏览器版本与驱动版本一致

posted @ 2019-04-25 19:48  Apple Zhang  阅读(291)  评论(0编辑  收藏  举报