java - Selenium Chrome 驱动程序的限制 Web 大规模抓取

标签 java selenium selenium-webdriver selenium-chromedriver google-chrome-headless

我计划在我的项目中使用 Selenium Chrome Driver,它将用于对多个公共(public)网站(如 kayak 或 skyscanner)进行网络抓取。因此,将有一个 REST GET 端点,我的后端将在其中启动 headless Chrome 以抓取多个网站,并最终返回一个经过处理的 JSON。

我想知道 Chrome 驱动程序的可扩展性如何,因为它听起来像是在收到请求时需要启动 headless Chrome 实例。

更新:使用 Google Chrome Headless 的问题

最佳答案

请找出我在实现过程中注意到的 phantom js 的优缺点。希望对您有所帮助。

Cons:

1)It will fail to recognize the browser elements like id,xpath,csselector
when compared to chrome driver.
2)If you have login mechanism ,redirects won't work as you expect when compared to chrome driver.
3)You need to manually implement the custom logic for screen shots for the test failures if you need it.
4)If you want to switch between multiple drivers like chrome,html etc then it is very difficult

Pros:

1)Test case execution is faster when compared to chrome driver
2)No browser is required it will run without GUI. 
3)No much configurations are needed when compared to chromedriver.

您也可以使用 html 驱动程序,它比 phantom 快得多,但即使它也有其自身的局限性,您需要在实现前注意这些局限性。

关于java - Selenium Chrome 驱动程序的限制 Web 大规模抓取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47038698/

相关文章:

java - Spring Java Config期间的加载顺序

java - Selenium 中 WebElements 与 WebElement 的区别

java - 如何使用 Java 设置 Selenium WebDriver?

java - 在 Java 中使用 Selenium 选择下拉值

python - 将 adblock 添加到 Chrome python selenium webdriver 时出错

java - 在 UML 中表示重载方法

java - 将 dd-MMM-yyyy 转换为 MM/dd/yyyy 格式

java - 使用 WebDriver 获取子元素

java - 如何模拟 ECG(心电图)

c# - 无法使用 Selenium WebDriver 在 Chrome 中加载默认配置文件