springspring-bootgoogle-chrome-headlessheadless-browserfirefox-headless

Embedding headless browser inside Spring Boot application?


For my Spring Boot application I need to be able to, in response to a request (HTTP request to a REST API) launch a headless browser, render some website (HTML+CSS+JS), perform some analysis and get the response back.

Previously I had built a prototype using JavaFX and was using this library https://github.com/MachinePublishers/jBrowserDriver

Do you know any other headless browser that can be embedded inside a Spring Boot application?

EDIT: For Node.js I think I'd try to use puppeteer


Solution

  • Spring Boot doesn't have any built-in support for headless browsers. So generally speaking, mentioning spring boot is irrelevant here. Hence I think you can use any headless browser than can be used from the/in conjunction with any java application even as an external process.

    In particular in order to run another application from Java you might want to read This article

    I can't really recommend any headless browser since I've never used any of those. I remember there is Phantom JS a browser that our automation team has used in one of my previous jobs, but probably there are others as well.

    You can also try to embed the browser you've mentioned into spring boot application.