I am working with scrapy with python.
I have this html node
<div class="comment-right-box">
<center>
<h3>
Call the Seller
</h3>
</center>
<div class="span1">055 176 1262</div>
</div>
I want to get the number inside the span1
normalize-space(.//div[@class='comment-right-box']/center/h3[contains(normalize-space(.), 'Call the Seller')]/parent/following-sibling::div[@class='span1']/text())
I got empty result.
what am I doing wrong?
There is no parent
node. You want the first ancestor:
normalize-space(//div[@class='comment-right-box']
/center/h3[contains(normalize-space(.), 'Call the Seller')]
/ancestor::*[1]/following-sibling::div[@class='span1']/text())
Or you could also use ../
normalize-space(//div[@class='comment-right-box']
/center/h3[contains(normalize-space(.), 'Call the Seller')]
/../following-sibling::div[@class='span1']/text())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.