[英]XPATH: How to target value after certain text or tag
I am new to using **XPath**
and this may be a basic question.我是使用**XPath**
新手,这可能是一个基本问题。 Kindly bear with me and help me in resolving the issue.请耐心等待并帮助我解决问题。
I would like to target the text that comes after the "Contact:" text.我想定位“联系人:”文本之后的文本。 The "Contact:" is wrapped in a <b>
tag. “联系人:”包含在<b>
标签中。 I want to target the name-value after the <b>
tag.我想在<b>
标签之后定位名称值。
I tried this xPath experession name = response.xpath('//div[@style="line-height: 1.5;"]/b').get()
but it only return the Contact: text.我试过这个 xPath experession name = response.xpath('//div[@style="line-height: 1.5;"]/b').get()
但它只返回 Contact: 文本。 I am interested in the text after this "Contact: " text.我对“联系方式:”文本之后的文本感兴趣。
<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>
Try:尝试:
//div//div[@style="line-height: 1.5;"]/normalize-space(text()[3])
or possibly:或者可能:
//div//div[@style="line-height: 1.5;"]//text()[preceding-sibling::br][1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.