Google表格ImportXML可以解析一个<small>但不是另一个<small>的结果

时间:2017-02-10 01:03:27

标签: xpath xhtml

我试图搜索Yelp结果列表中的餐馆名称,地址和距离给定地址的距离。我能够获取餐馆名称和地址,但我似乎无法获得距离。

enter image description here

我想抓取0.1 km文本,这个文本位于<ul>块中,如下所示:

<ul class="search-result_tags">
    <li class="tag-18x18_marker-error">
        <small>
            <span aria-hidden="true" style="width: 18px; height: 18px;" class="icon icon--18-marker icon--size-18 icon--error">
                <svg class="icon_svg">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#18x18_marker"></use>
                </svg>
            </span>

                    0.2 km
        </small>

    </li>
    <li class="tag-18x18_checkmark-neutral-gray">
        <small>
            <span aria-hidden="true" style="width: 18px; height: 18px;" class="icon icon--18-checkmark icon--size-18 icon--neutral-gray">
                <svg class="icon_svg">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#18x18_checkmark"></use>
                </svg>
            </span>

                    Good for Lunch
        </small>

    </li>
</ul>

我用过:

=IMPORTXML("https://www.yelp.ca/search?find_desc=lunch&find_loc=1+Hacker+Way,+Menlo+Park,+CA,+United+States&start=0&rpp=40&attrs=GoodForMeal.lunch,RestaurantsPriceRange2.1,RestaurantsPriceRange2.2", "//li[@class='tag-18x18_marker-error']//small")

结果我得到#N / A. 但是,当我更改@class值以取代Good for Lunch文字时,Google表格中显示的效果非常好。

我错过了什么?据我所知,两个文本值以相同的方式显示,但我无法弄清楚为什么一个有效,另一个没有。任何帮助表示赞赏!

0 个答案:

没有答案
相关问题