Scrapy SgmlLinkExtractor how go get number inside span tag
<p>How can I get the integer number highlighted at this specific location:</p>

<p><a href="http://i.stack.imgur.com/YDsY4.png" rel="nofollow"><img src="http://i.stack.imgur.com/YDsY4.png" alt="number inside span tag"></a></p>

<p>I got the follwing XPath from Google Chrome:</p>

<pre><code>//*[@id="page"]/main/div[4]/div[2]/div[1]/div/div/div[2]/div[4]/div/div[1]/span
</code></pre>

<p>So I definded the following XPath statement with srapy to retreive the number:</p>

<pre><code>id = response.xpath('//*[@id="page"]/main/div[4]/div[2]/div[1]/div/div/div[2]/div[4]/div/div[1]/span').extract()
</code></pre>

<p>However the variable id remains empty, my spider doesn't seem to crawl any information. How should I rewrite the statement to have access to this specific element?</p>

<p>As a rule, to avoid later debugging to have a stable run you need to avoid using absolute xpath's or any xpath that is not flexible on minor changes of the page structure.</p>

<p>From the information available in the picture, your xpath should be:</p>

<pre><code>//*[@class='nr']/span
</code></pre>

<p>For basic overview of the xpath rule you can take a look on <a href="http://www.w3schools.com/xsl/xpath_syntax.asp" rel="nofollow">w3schools xpath selectors</a></p>

python regex xpath scrapy