5
我想使用Jsoup提取html中的特定内容。以下是示例html内容。使用Jsoup提取跨度标记数据
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body class="">
<div class="shop-section line bmargin10 tmargin10">
<div class="price-section fksk-price-section unit">
<div class="price-table">
<div class="line" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
<div class="price-save">
<span class="label-td"><span class="label fksk-label">Price :</span></span>
</div>
<span class="price final-price our fksk-our" id="fk-mprod-our-id">Rs.<span class="small-font"> </span>11990</span>
</div>
<meta itemprop="price" content="Rs. 11990" />
<meta itemprop="priceCurrency" content="INR" />
<div class="our-price-desc fksk-our-price-desc">
<small>(Prices are inclusive of all taxes)</small>
</div>
</div>
</div>
</div>
</body>
</html>
我用下面的命令所需的输出:
document.select(".price-table").select(".line").select("span").get(2).text()
看起来像其漫长的。 我不能直接使用跨班级(“价格最终价格我们的fksk-我们”)?
对此有何帮助?
许多感谢AHungerArtist,您提供的解决方案工作正常。我发现“price-table”div类在整个html中是独一无二的,所以我选择了这个类。 – topblog 2012-02-25 17:57:40