XPath 不包含文本
XPath Not contains text
这是我的代码:
plantas = tree.xpath('//td[contains(text(),"terreno") or text[not(contains(text(),"terreno"))]]/preceding-sibling::td[1]/text()')
如何让我的 xpath 获取单词 "terreno" 之前的值或即使没有单词也获取它?我上面的代码不起作用。
下图中,第二个没有抓住“1 planta”
这是您需要的 XPath(因为前一个似乎不一致):
//td[@class="tituloresult"]/following::td[@style and contains(text(),"planta")]
在目标的前 10 页上完美运行 website。
注意:
XPath 表达式将排除突出显示的广告。因此,每页将获得 22 到 24 个结果。
编辑:表面积:
//td[@class="tituloresult"]/following::td[@style and contains(text(),"terreno")]
或(包含没有文本的元素):
//td[@class="tituloresult"]/following::td[@style][3]
这是我的代码:
plantas = tree.xpath('//td[contains(text(),"terreno") or text[not(contains(text(),"terreno"))]]/preceding-sibling::td[1]/text()')
如何让我的 xpath 获取单词 "terreno" 之前的值或即使没有单词也获取它?我上面的代码不起作用。
下图中,第二个没有抓住“1 planta”
这是您需要的 XPath(因为前一个似乎不一致):
//td[@class="tituloresult"]/following::td[@style and contains(text(),"planta")]
在目标的前 10 页上完美运行 website。
注意: XPath 表达式将排除突出显示的广告。因此,每页将获得 22 到 24 个结果。
编辑:表面积:
//td[@class="tituloresult"]/following::td[@style and contains(text(),"terreno")]
或(包含没有文本的元素):
//td[@class="tituloresult"]/following::td[@style][3]