How do I get the span with a certain text within an attribute? I am trying to extract the number that comes after the text "stars". So how can I select a span tag that has text "rating_sprite stars" and I want the value "star5" to be extracted from the attribute so that I can get 5 out of the text.
Currently I dont get any elements back!
String url = "https://www.morningstar.co.uk/uk/funds/snapshot/snapshot.aspx?id=F00000WYA1";
Document doc = null;
try {
doc = Jsoup.connect(url).get();
} catch (IOException e) {
e.printStackTrace();
}
Elements spans = doc.select("span.rating_sprite");
System.out.println(spans);
the HTML snippet looks something like this
<div class="snapshotTitleBox">
<h1>Comgest</h1>
<span class="rating_sprite stars5"></span>
<span class="rating_sprite analyst-rating-5"></span>
<div style="float:right; margin-top:6px;"></div>
</div>