【发布时间】:2012-02-25 17:31:20
【问题描述】:
我正在尝试使用 Jsoup 提取 html 中的特定内容。以下是示例 html 内容。
<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()
看起来很长。 我不能直接使用 span 类(“price final-price our fksk-our”)吗?
对此有任何帮助吗?
【问题讨论】:
标签: java web-crawler jsoup