To add to Janez's correct answer - while jsoup's CSS selector (currently) doesn't support escaping a :
character in the class name, there are other ways to get it to work if you want to use the select()
method instead of getElementsByXXX
-- e.g. if you want to combine selectors in one call:
Elements divs = doc.select("div[class=website text:middle]");
That will find div
elements with the literal attribute class="website text:middle"
. Example.
Or:
Elements divs = doc.select("div[class~=text:middle]");
That finds elements with the class attribute that matches the regex /text:middle/
. Example
For the presented data though, I think think the getElementsByClass()
DOM method is the way to go and the most general. I just wanted to show a couple alternatives for other cases.