scrapy xpath can't get values
<p>I have a website and i would like to save two span element value.</p>

<p>This is the relevant part of my html code:</p>

<pre class="lang-html prettyprint-override"><code>&lt;div class="box-search-product-filter-row"&gt;

    &lt;span class="result-numbers" sth-bind="model.navigationSettings.showFilter"&gt;

    &lt;span class="number" sth-bind="span1"&gt;&lt;/span&gt;

    &lt;span class="result" sth-bind="span2"&gt;&lt;/span&gt;

    &lt;/span&gt;

&lt;/div&gt;
</code></pre>

<p>I create a spider:</p>

<pre><code>from scrapy.spiders import Spider
from scrapy.selector import Selector

class MySpdier(Spider):

    name = "list"
    allowed_domains = ["example.com"]
    start_urls = [
        "https://www.example.com"]

    def parse(self, response):
        sel = Selector(response)
        divs = sel.xpath("//div[@class='box-search-product-filter-row']")


        for div in divs:
            sth = div.xpath("/span[class='result']/text()").extract()

            print sth
</code></pre>

<p>When I crawl the spider, it prints only this:</p>

<p><code>[]</code></p>

<p>Can anybody help me how can I get the values from my two (class number, and class result) span element?</p>

<p>You forgot <code>@</code> in your xpath <code>"/span[class='result']/text()"</code>. Furthermore the span you are looking for is not a 1st level child so you need to use <code>.//</code> instead of <code>/</code>. See:
<a href="http://i.stack.imgur.com/xPxff.png" rel="nofollow"><img src="http://i.stack.imgur.com/xPxff.png" alt="enter image description here"></a>
Source: <a href="http://www.w3schools.com/xsl/xpath_syntax.asp" rel="nofollow">http://www.w3schools.com/xsl/xpath_syntax.asp</a></p>

<p>Complete and correct xpath would be: <code>".//span[@class='result']"</code> + '/text()' if you want to select only the text, but the nodes in your example have no text so it wouldn't work here.</p>

python xpath scrapy scrapy-spider