gpt4 book ai didi

android - 在 android 中使用 jsoup 获取
标签内的内容

转载 作者:行者123 更新时间:2023-11-30 02:48:42 24 4
gpt4 key购买 nike

如何在 android 中使用 jsoup 获取标签内的内容?

我搜索了很长时间,但没有找到任何有用的东西。我真的不知道该怎么办。我在下面写下了所有细节。我已经尝试过但没有成功。

我的 html 代码:

<div id="content-post">
<article class="post clearfix">
<figure class="post-image"></figure>
<header></header>
Line 1
Line 2
<br></br>
<br></br>
Line 4
Line 5
Line 6
Line 7
<br></br>
<br></br>
Line 8
Line 9
<br></br>
<br></br>
Line 10
Line 11
<p></p>
<div class="news_detail">
<div class="news_soc"></div>
</div>
</article>
</div>

我需要乘坐 1 号线到 11 号线。我想把它们放到一个数组中。

更新:

<div id="content-post">
<article class="post clearfix">
<figure class="post-image">
<img src="../../../../../upload/news/2014/07/large/JuiR1404499837lucxqg.jpg" />
<h1>Agree</h1>
</figure>
<header>
<p class="post-meta">2014</p>
</header> Line 1
Line 2
<br></br>
<br></br>
Line 4
Line 5
Line 6
Line 7
<br></br>
<br></br>
Line 8
Line 9
<br></br>
<br></br>
Line 10
Line 11
<p></p>
<div class="news_detail">
<div class="news_soc">
<a href="https://plus.google.com/share?" target="_blank"><img alt="Google+" src="../../../../theme/image/soc_gp.jpg"></a>
<a href="https://twitter.com/intent/tweet/" target="_blank"><img alt="Twitter" src="../../../../theme/image/soc_tw.jpg"></a>
<a href="https://www.facebook.com/sharer/" target="_blank"><img alt="Facebook" src="../../../../theme/image/soc_fb.jpg"></a>
</div>
<div class="news_auth">
Send By Jack
</div>
</div>
</article>
</div>

我的代码:

 int timeOut = 30 * 1000;// 30 second.
String url =CommonMethods.getCurrentSite() + URLEncoder.encode(news.getLink(), "UTF-8").replace("%2F","/");
_doc = Jsoup.connect(url)
.timeout(timeOut)
.get();
if (isCancelled()) { // If Cancel Read Content News return Null
return null;
}
_ContentRegion = _doc.getElementById("content-post");

//I really do not know what to do.

最佳答案

我发现:

_ContentRegion = _doc.getElementById("content-post").select("article > p");
for (Element ee : _ContentRegion){
Log.d("ownText",ee.ownText());
}

关于android - 在 android 中使用 jsoup 获取 <article> 标签内的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585959/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com