Reputation: 4807
I wish to parse IMBD page to get the movie rating. (Please do not offer me APIs). This is my code (for now):
private static class getData extends AsyncTask<String, String, Void>
{
String url = "https://www.imdb.com/title/tt0437086/";
@Override
protected Void doInBackground(String... strings) {
try {
Document document = Jsoup.connect(url).get();
Elements img = document.select("span");
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
I get all the span, but do I need to cycle all of them to find the rating? What I need is the rating from this line (specifically the rating itself):
<span itemprop="ratingValue">7.5</span>
How can I get the rating without cycling trough all elements?
Upvotes: 1
Views: 30