Answer the question
In order to leave comments, you need to log in
How to parse data from localhost:8080 using Jsoup?
Is there such a possibility at all?
I have 10 containers with class="card", here is the code:
try {
Document doc = Jsoup.connect("http://localhost:8080/configurator").get();
Elements cards = doc.getElementsByAttributeValue("class", "card");
System.out.println(cards.size());
} catch (IOException ex) {
ex.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
I looked at the source code of the project and everything fell into place.
First, this project uses Vaadin. Unfortunately, I haven't had a chance to use it, but I can say this:
Page content is rendered dynamically on the client. JSoup does not know how to work with dynamically generated content, and therefore, at the time of document parsing, there is only:
<div id="outlet"></div>
Accordingly, in order to parse dynamic content, you need to:
1) either study the internal API and parse the json that is returned from the outside. Go to the Network tab of your browser and filter the XHR requests and see which endpoint the request is made to and what is returned in response.
2) either parse the site using Selenium. (launch browser, wait for page to load, get document, get List<WebElement>
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question