java使用单个类名从html标记中获取文本,html标记将包含多个类
我有一个html行,其中标签中有标签,一个标签包含多个类。我需要用单个类名提取文本(我只知道一个类名)
<p class="Body1"><span class="style3"></span><span class="style1">W</span><span class="Allsmall style5">extract this text </span><span class="style5">unwanted text </span></p>
我只知道类名Allsmall,我想使用java中的Jsoup从html行中提取文本“ExtractThisText”
# 1 楼答案
您可以使用选择器语法根据特定元素的CSSclass属性检索该元素: