【发布时间】:2014-08-25 13:55:47
【问题描述】:
我正在 YQL 控制台中进行查询,内容如下:
select * from html
where url='http://www.motorni-masla.net/index.php?main_page=product_oil_info&cPath=140&products_id=294&zenid=c8281021bbfed454176247900b3b9d4a'
and xpath='//*[@id="productPrices"]'
idiea 是找出 id 为“productPrices”的元素,并以 JSON 格式返回它的内容。
但是当我这样做时 - 结果与原始代码不同 - 有额外的标签。
原创内容:
<strong>
<h2 id="productPrices" class="productGeneral">
<span class="normalprice">14.00лв. </span> <span class="productSpecialPrice">11.00лв.</span><span class="productPriceDiscount">
<br>Спести: 21% отстъпка</span>
</h2>
</strong>
YQL 结果:
{
"h2": {
"class": "productGeneral",
"id": "productPrices",
"strong": {
"span": [
{
"class": "normalprice",
"content": "14.00лв."
},
{
"class": "productSpecialPrice",
"content": "11.00лв."
},
{
"class": "productPriceDiscount",
"br": null,
"content": "\nСпести: 21% отстъпка"
}
],
"content": " "
}
基本上在原始内容中 - 顺序是:
strong -> h2 -> span
在 YQL 结果中是:
h2 -> strong -> span
这使得我拥有的 XPATH 毫无用处,因为我不能在 YQL 语句中使用它——它不符合 YQL 得到的结果。
在另一种情况下,不仅顺序不同,而且从现在添加了一个<p>标签。
如果有人告诉我这里发生了什么,我将不胜感激。
【问题讨论】: