安装客户端库
pip install selenium
安装浏览器驱动(chrome)
https://chromedriver.storage.googleapis.com/index.html
下载 chromedriver_win32.zip,解压至d:\webdrivers\chromedriver.exe(注意放在没有空格和中文的目录)
下面的代码, 可以自动化的 打开Chrome浏览器,并且自动化打开百度网站,可以大家可以运行一下看看。
from selenium import webdriver
# 创建 WebDriver 对象,指明使用chrome浏览器驱动
wd = webdriver.Chrome(r'd:\webdrivers\chromedriver.exe')
# 调用WebDriver 对象的get方法 可以让浏览器打开指定网址
wd.get('https://www.baidu.com')