Reputation: 113
Hello I would like to get the value following "cotation" but I don't know how to do it.
<span id="brs-sl57350199c5a53">
<span class="cotation">16.33 (c)</span>
</span>
I'm using Jsoup and this my code:
Document doc = Jsoup.connect("http://www.boursorama.com/bourse/actions/cours_az.phtml").get();
Element loginform = doc.getElementById("content"); //brs-sl5734ff406037d
Elements inputElements = loginform.getElementsByTag("span");
for (Element inputElement : inputElements) {
String key = inputElement.attr("class");
System.out.println("Param name: "+ key);
}
And this is what I have:
Param name: cotation
Do you have any idea to be able to get the value instead of "cotation"?
Thanks in advance.
Upvotes: 1
Views: 804
Reputation: 494
Add this in your loop :
if ("cotation".equals(key)) {
System.out.println(inputElement.html());
}
And you will get :
16.33 (c)
Upvotes: 1