Reputation: 417
Basically I have javafx' WebEngine
and I want to parse contents of current webpage using Jsoup instead of built-in w3c. But webEngine.getDocument()
returns w3c's Document
and I can't find any good way to convert it to Jsoup's one. The only way I can think about right now is converting original Document
to String and then parsing it with Jsoup, which is quite clumsy
Upvotes: 4
Views: 453
Reputation: 10650
That's the way I do it and it works nicely.
WebEngine webEngine = webView.getEngine();
String html = (String) webEngine.executeScript("document.documentElement.outerHTML");
I then pass the string "html" to JSoup.
Upvotes: 1