动态渲染页面爬取-Selenium & Splash

模拟浏览器的动机

  • JS动态渲染的页面不止Ajax一种
  • 很多网页的Ajax接口含有加密参数,分析其规律的成本过高

通过对浏览器运行方式的模拟,我们将做到:可见即可爬
Python中常用的模拟浏览器运行的库为Selenium和Splash

Splash

Selenium

Selenium是一个自动化测试工具,可以用来控制浏览器行为

  1. QuickStart:https://seleniumhq.github.io/selenium/docs/api/py/
  2. 完整文档:https://www.seleniumhq.org/docs/
  3. Python接口:https://seleniumhq.github.io/selenium/docs/api/py/api.html

常用接口:

原文地址:https://www.cnblogs.com/lokvahkoor/p/10775897.html