一、查看Chrome 版本二、下载 ChromeDriver三、安装selenium四、环境配置五、验证安装
一、查看Chrome 版本
根据自己查到的版本到 ChromeDriver 镜像站下载对应的安装包,在不同平台下,可以下载不同的安装包。
镜像站链接如下:
https://chromedriver.storage.googleapis.com/index.html
pip install selenium四、环境配置
最简单粗暴的方法,将上述在镜像站下载的压缩包进行解压,将解压的chromedriver.exe 放到Python 的 scripts 目录下。
from selenium import webdriver
import time
def main():
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
time.sleep(5)
driver.quit()
if __name__ == '__main__':
main()
运行之后,能看到百度页面,代表安装成功。(页面会在5s后关闭)



