pip install selenium

因为phantomJS将停止维护,所以建议使用headless chrome
ChromeDriver is a separate executable that WebDriver uses to control Chrome.

1、确保谷歌浏览器安装在可以找到的位置(默认位置或自己指定的位置)。
如果不是默认位置,则需要用下面的代码来指定谷歌浏览器的安装位置:
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");

2、下载你系统上所需要的ChromeDriver文件,windows所需下载地址为:
https://chromedriver.storage.googleapis.com/index.html?path=2.35/

3、帮助WebDriver找到你下载的ChromeDriver文件:
将ChromeDriver文件存放在PATH目录下或

from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver')

4、(可选)启动和退出ChromeDriver server需要一些时间,所以提供了两种方法来
解决这个问题:
1、使用ChromeDriverService
2、作为一个服务器单独启动ChromeDriver server,然后用Remote WebDriver连接它。

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com")
print(driver.title)
driver.quit()

参考链接:
https://sites.google.com/a/chromium.org/chromedriver/home 介绍地址
https://sites.google.com/a/chromium.org/chromedriver/getting-started 入门地址

最新文章

  1. os.path 大全
  2. jquery---基本标签
  3. spring4 文件下载功能
  4. JSPatch 遇上swift
  5. Android类库常用类库一览
  6. (转)CSS+DIV float 定位
  7. Codeforces Round #327 (Div. 1) D. Top Secret Task
  8. adb shell dumpsys 命令 查看内存
  9. 目前比较流行的Python科学计算发行版
  10. mybatis源码之MapperMethod
  11. Android--app性能问题的总结(一)
  12. 高德地图 Service 创建服务 USERKEY_PLAT_NOMATCH
  13. Ubuntu 18.04.1安装Nginx
  14. BootStrapTable 错误
  15. vue-cli(vue脚手架)超详细教程
  16. loadrunner 更新中......
  17. 【转】Android开源项目(非组件)
  18. Odoo前端页面模版渲染引擎——Jinja2用法教程
  19. 【转】netty源码分析之LengthFieldBasedFrameDecoder
  20. asp.net线程批量导入数据时通过ajax获取执行状态

热门文章

  1. [GUI] Linux中的图形管理
  2. Python的文件读写与存储
  3. python中threading多线程
  4. CentOS 7 导入epel库
  5. Spring中为什么实体类不用注入
  6. FIND_IN_SET的简单使用
  7. 基于Spring mvc 的Websocket 开发
  8. 并发Socket程序设计
  9. Codeforces Round #366 (Div. 2) A , B , C 模拟 , 思路 ,queue
  10. Redis缓存集群方案