I want to load web content from a site URI and use selectors to get some useful information. I tried JSoup which allows me to select elements with a CSS Selector. Unfortunately Jsoup doesn't work as a browser and doesn't parse Javascript or handles cookies. That's why I looked into using the JavaFX WebEngine which works as a browser. But The WebEngine class returns Documents which are very limited in selector possibilities compared to JSoup. The only selectors are by Id or by Tag.
Is there a clean way to use the WebEngine of JavaFX with more specialized selector possibilities?
Or are there other browser implementations in Java that allow for more specialized selections? The implementation should preferably be fast.
The best solution I can come up with for now is the following:
- Use WebEngine of JavaFX to get a Document object of which the Javascript is parsed.
- Convert the Document to a String using a Transformer.
- Pass this String as argument to a JSoup object and use their CSS selector capabilities.