selenium库可以指挥浏览器自动工作,除了正常的安装调用之外,还需要设置浏览器引擎。

优点:简单直观;缺点:爬取大量数据时,有点慢;通常是其他方法无法解决或者很难解决时才会用到这个库。

# 本地Chrome浏览器设置方法
from selenium import webdriver #从selenium库中调用webdriver模块
driver = webdriver.Chrome() # 设置引擎为Chrome,真实地打开一个Chrome浏览器

1.获取数据

Python学习之selenium库

2.解析数据

#提取一个元素

Python学习之selenium库

#提取多个元素,把element换成elements

Python学习之selenium库 

3.提取数据

4.自动操作浏览器

Python学习之selenium库

5.浏览器静默模式

Python学习之selenium库

相关文章:

  • 2021-09-28
  • 2021-10-28
  • 2021-12-27
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-19
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-01-22
相关资源
相似解决方案