刮擦:X 路径选择祖先不是页脚的所有页眉



我正在尝试获取所有不在页脚中的标题。

因此,应从抓取中排除标头<h3 class="ibm-bold">Discover</h3>

<footer role="contentinfo" aria-label="IBM">
   <div class="region region-footer">
   <div id="ibm-footer-module">
    <section role="region" aria-label="Resources">
            <h3 class="ibm-bold">Discover</h3>

我尝试使用此表达式来选择应排除的标头,但它没有返回正确的节点。

//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6]/ancestor::footer/text()

我正在抓取的页面是这样的:https://www.ibm.com/products/informix/embedded-for-iot?mhq=iot&mhsrc=ibmsearch_a

请帮忙

你几乎拥有了它。

//*[
  (self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6)
  and not(ancestor::footer)
]/text()

最新更新