0
How do I make sure he only passes the €1.25 part to String? https://www.pingodoce.pt/produtos/tab-choc-negro-nestle-100g/
0
How do I make sure he only passes the €1.25 part to String? https://www.pingodoce.pt/produtos/tab-choc-negro-nestle-100g/
1
Analyzing html, there is only one element with class realprice
on the page, then you can make a selector for that class. I am only considering the page you provided in the question, how missing details is 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€
Thank you very much can explain to me , what does the . realprice?
How did you parse html?
Just go to the page, right click on the element and "inspect element". Most browsers have this feature. When there isn’t, just press Ctrl+u on any page to display the source code. :)
select(".realprice")
selects all elements that have the class realprice
in html.
thank you very much! congratulations rest of a good day saved me even
Browser other questions tagged java jsoup
You are not signed in. Login or sign up in order to post.
I removed the tags android and android-studio because the Jsoup is a html parser wherever it is running from. It doesn’t matter if it’s Android, desktop, web, etc...
– Renan Gomes