How do I get jsoup to only pass specific parts of the site?

0

How do I make it spend only part of the 1.25 € for String? link

    
asked by anonymous 06.07.2017 / 13:31

1 answer

1

By analyzing html, there is only one element with class realprice on the page, so you can make a selector for that class. I'm only considering the page that you provided in the question, as details are missing, it's what you can answer.

Document document = Jsoup.connect("https://www.pingodoce.pt/produtos/tab-choc-negro-nestle-100g/")
                         .get();

// Pegando o índice "0" porque só há um elemento.
final String price = document.select(".realprice").get(0).text();

System.out.println("preço: " + price); // preço: 1.25€
    
06.07.2017 / 13:41