selenium-环境搭建(基于python)

selenium环境搭建(基于python语言)

1、浏览器

谷歌浏览器下载:https://google.cn/chrome/index.html

火狐浏览器下载:https://www.firefox.com.cn/

2、安装与浏览器对应版本的驱动(查看浏览器版本chrome://version/)

谷歌驱动下载:https://registry.npmmirror.com/binary.html?path=chromedriver/

火狐驱动下载:https://registry.npmmirror.com/binary.html?path=geckodriver/

3、将驱动解压后放进path环境变量中

解压后得到的谷歌驱动chromedriver.exe,火狐驱动geckodriver.exe,移动到python安装目录即可(如下图)

 

4、在python中安装selenium模块

pip安装,打开cmd命令框,输入:pip install selenium

# 检查环境是否安装成功
from time import sleep

from selenium import webdriver

w=webdriver.Chrome()
w.maximize_window()
w.implicitly_wait(3)
w.get("https://www.baidu.com")
sleep(10)
w.quit()

 

posted on 2022-08-09 16:44  ×不知该怎么√  阅读(43)  评论(0编辑  收藏  举报

导航