java如何用jsoup解析span title?
我正在尝试使用JSOUP解析此内容的标题
<div class="article">
<div class="articleHead review">
<h1 class="item"><span class="fn">OnLive</span> review</h1>
<h2 class="subGrey"><span class=""></span>Cloud gaming has arrived in the UK, but can our infrastructure make the most of it?</h2>
我想解析span类OnLive Review。 还有副标题
我已经试过了
try{
Elements titleElements = jsDoc.getElementsByTag("div");
for(Element TitleElement : titleElements){
if(TitleElement.attr("class").equals("articleHeader review")){
Element articleHeader = jsDoc.select("#item").first();
String header = articleHeader.text();
System.out.println(TitleElement.text());
title = header.toString();
Log.e("TITLE", title);
}
}
}
catch(Exception e){
System.out.println("Couldnt get content");
}
不走运
# 1 楼答案
好了: