1

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

I tried this xpath

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?

Please don't suggest going directly to the span1 class

Marco Dinatsoli
  • 10,322
  • 37
  • 139
  • 253

1 Answers1

1

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())
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Could you check my question please http://stackoverflow.com/questions/24109713/scrapy-spider-sends-spider-close-signal-before-it-closes – Marco Dinatsoli Jun 08 '14 at 19:19