一、selenium是什么?
示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。
二、使用步骤
1.下载selenium
代码如下(示例):
pip install selenium
2.下载驱动
Chrome驱动:
官网链接
https://chromedriver.chromium.org/
淘宝镜像
https://npm.taobao.org/mirrors/chromedriver/
3. 配置驱动
- 添加环境变量
vim ~/.bash_profile
添加:
export PATH=$PATH:驱动所在文件夹路径
- 将驱动放到python文件目录下
webdriver.Chrome(executable_path='./chromedriver')
4. 测试代码片段
from selenium import webdriver
driver = webdriver.Chrome(executable_path='./chromedriver')
driver.get('https://www.baidu.com/')
driver.close()