我使用此代码但不是真的!!!为什么……?
String url = "http://example.com";
ProgressDialog mProgressDialog;
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document document = Jsoup.connect(url).get();
// Using Elements to get the Meta data
Elements description = document
.select("div[class=title]");
// Locate the content attribute
desc = description.attr("content");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
如果我的html代码是
<div class="text-co">
<div class="title"><a href="">00</a>
<a href="">11</a>
<a href="">22</a>
</div>
</div>
<div class="text-co">
<div class="title"><a href="">33</a>
<a href="">44</a>
<a href="">55</a>
</div>
</div>
我想展示
00
11
22
33
44
55
在我的 jsoup android 应用程序中,我应该做什么
最佳答案
试试这段代码:
Elements anchors = document.select("div.title > a");
for(Element anchor : anchors) {
Strig description = anchor.text();
// ...
}
关于android - 如何通过 JSOUP 从 android 中具有类 ="title"的 div 获取所有文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30691487/