【问题标题】:Web Scraping - xPath issue网页抓取 - xPath 问题
【发布时间】:2018-11-21 03:41:00
【问题描述】:

我需要从这个 HTML 代码中提取文本 120

<section class="details">
    <h2>Détails du bien</h2>

        <table>
            ....
            <tr>
                <td>Surface habitable (m²)</td>
                <td class="right" title="120">120 </td>
            </tr>
            ...
        </table>
</section>

我使用了这个 xpath,但它返回一个空列表:

//td[contains(text(),"Surface")]/td[@class="right"]/text()

我做错了什么?

【问题讨论】:

    标签: xpath web-scraping


    【解决方案1】:

    尝试使用xPath axes:

    //td[contains(text(),"Surface")]/following-sibling::td[@class="right"]/text()

    这应该可以解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-03
      • 2021-07-25
      • 1970-01-01
      • 2016-02-05
      • 2015-06-26
      相关资源
      最近更新 更多