XPATH: How to target value after certain text or tag

Viewed 210

I am new to using **XPath** and this may be a basic question. Kindly bear with me and help me in resolving the issue.

Link is here...

I would like to target the text that comes after the "Contact:" text. The "Contact:" is wrapped in a <b> tag. I want to target the name-value after the <b> tag.

I tried this xPath experession name = response.xpath('//div[@style="line-height: 1.5;"]/b').get() but it only return the Contact: text. 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>&nbsp;<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>

enter image description here

1 Answers

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]
Related