Python 之selenium3 环境搭建

1.selenium3环境搭建

1.1下载对应的浏览器驱动

Chrome : https://chromedriver.storage.googleapis.com/index.html
(只要大版本对应得上就可以了)
Firefox : https://github.com/mozilla/geckodriver/releases
(通用)
IE : http://docs.seleniumhq.org/download/

1.2配置浏览器驱动

把下载好的浏览器驱动解压放置在Python的安装目录下

2.Python 安装 selenium

2.1下载第三方库

命令行输入pip install selenium

2.2导入第三方库

# 导入selenium中的webdriver
from selenium import webdriver
# 导入时间包
from time import sleep
# 选择打开浏览器
# driver = webdriver.Chrome() # 谷歌
driver = webdriver.Firefox()  # 火狐
# 输入的网址
url = "https://baidu.com"
# 打开指定的网页
driver.get(url)
# 操作网址
pass
sleep(10)
# 关闭浏览器
driver.close()

猜你喜欢

转载自blog.csdn.net/qq_39286483/article/details/104202483