0
這是一段HTML,從中我想提取信息:條件XPath語句
<li>
<p><strong class="more-details-section-header">Provenance</strong></p>
<p>Galerie Max Hetzler, Berlin<br>Acquired from the above by the present owner</p>
</li>
我想有一個XPath表達式取決於是否有其提取第二<p> ... </p>
的內容與<p> ... Provenance ... </p>
此之前,一個兄弟就是在那裏我得到迄今:
if "Provenance" in response.xpath('//strong[@class="more-details-section-header"]/text()').extract():
print("provenance = yes")
但我怎麼去Galerie Max Hetzler, Berlin<br>Acquired from the above by the present owner
?
我試圖
if "Provenance" in response.xpath('//strong[@class="more-details-section-header"]/text()').extract():
print("provenance = yes ", response.xpath('//strong[@class="more-details-section-header"]/following-sibling::p').extract())
但我得到[]
或者更精確地說「// P [前同輩:: P [1] = '種源'] /文本()」 – SIM