문제

I have the following html code

<span class="tag" style="font-size: 12px;"><a href="/tag/Black+Library" target="_top">Black Library</a><span class="count"> (1)</span> </span> 

and i want to retrieve number "(1)" from class count inside class tag... how can i do that with jsoup?

code like

Elements num = document.select(".tag count");

is not working.

In fact i want both the "tag" Black Library and the "count" 1.. Any help to do that?

PS. there is another class count, for which the html code is

<li class="gap"><a href="/work/9767358/reviews/78536487">Reviews</a> <span class="count">(0)</span></li>

but i dont want that result.

도움이 되었습니까?

해결책

Elements num = document.select(".tag count");

This will select elements with class="tag" attribute and then it will in its children look for <count> elements. But you actually want to look for elements with class="count" attribute. Fix the CSS selector accordingly:

Elements num = document.select(".tag .count");

See also:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top