[英]XPATH: How to target value after certain text or tag
我是使用**XPath**
新手,這可能是一個基本問題。 請耐心等待並幫助我解決問題。
鏈接在這里...
我想定位“聯系人:”文本之后的文本。 “聯系人:”包含在<b>
標簽中。 我想在<b>
標簽之后定位名稱值。
我試過這個 xPath experession name = response.xpath('//div[@style="line-height: 1.5;"]/b').get()
但它只返回 Contact: 文本。 我對“聯系方式:”文本之后的文本感興趣。
<div class="vcard">
<h2><a class="fn org" target="_blank" title="https://patientcaremedical.com" href="https://patientcaremedical.com" onclick="trackClick(32589, 0)">Patient Care Medical</a><sup> <font color="red" size="2"><b>New!</b></font></sup></h2>
<div style="line-height: 1.5;">
<a title="info [at] patientcaremedical [.] com" href="/Patient_Care_Medical/rfq/sid32589.htm"><b><font color="red">Click Here To EMAIL INQUIRY</font></b></a>
<br><b>Contact: </b>Michael Blanchette - Marketing Director
<br>
嘗試:
//div//div[@style="line-height: 1.5;"]/normalize-space(text()[3])
或者可能:
//div//div[@style="line-height: 1.5;"]//text()[preceding-sibling::br][1]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.