我需要从使用XPath的编码中获得7.68美元的购买。我需要以下列格式回答:
//a[starts-with(@href, 'mailto')]/text()
<button class="price buy id-track-click" data-server-cookie="CAIaIgoeEhwKFmNvbS5tb2phbmcubWluZWNyYWZ0cGUQARgDQgA=" data-uitype="200">
<span>
<span itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
<meta content="https://play.google.com/store/apps/details?id=com.mojang.minecraftpe&rdid=com.mojang.minecraftpe&rdot=1&feature=md" itemprop="url">
<meta content="" itemprop="previewUrl">
<meta content="" itemprop="offerType">
<meta content="$7.68" itemprop="price">
<meta content="" itemprop="description">
<span itemprop="seller" itemscope="itemscope" itemtype="http://schema.org/Organization">
<meta content="Android" itemprop="name">
</span>
</span>
</span>
<jsl jsl="$x 1;$t t-nH6Xd1T8X0Y;$x 0;">
<jsl jsl="$x 1;$t t-R7hS--kHwck;$x 0;"> <span jsl="$x 1;" style="display:none" jsan="5.display"></span> </jsl>
</jsl>
<span>$7.68 Buy</span>
</button>
答案 0 :(得分:1)
meta
元素的价格为itemprop="price"
:
//meta[@itemprop="price"]/@content
答案 1 :(得分:1)
鉴于格式正确,
<button class="price buy id-track-click"
data-server-cookie="CAIaIgoeEhwKFmNvbS5tb2phbmcubWluZWNyYWZ0cGUQARgDQgA="
data-uitype="200">
<span>
<span itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
<meta content="https://play.google.com/store/apps/details?id=com.mojang.minecraftpe
&rdid=com.mojang.minecraftpe&rdot=1&feature=md"
itemprop="url"/>
<meta content="" itemprop="previewUrl"/>
<meta content="" itemprop="offerType"/>
<meta content="$7.68" itemprop="price"/>
<meta content="" itemprop="description"/>
<span itemprop="seller" itemscope="itemscope"
itemtype="http://schema.org/Organization"/>
<meta content="Android" itemprop="name"/>
</span>
</span>
<jsl jsl="$x 1;$t t-nH6Xd1T8X0Y;$x 0;">
<jsl jsl="$x 1;$t t-R7hS--kHwck;$x 0;">
<span jsl="$x 1;" style="display:none" jsan="5.display"></span>
</jsl>
</jsl>
<span>$7.68 Buy</span>
</button>
以下XPath表达式将根据请求返回$7.68 Buy
。
//span[ends-with(., 'Buy')]/text()
//span['Buy' = substring(., string-length(.) - string-length('Buy') + 1)]/text()