How to get last OPTION from SELECT list using XPath - Scrapy
<p>I am using this selector but it is giving error</p>

<p><code>//*[@id="quantity"]/option/[last()-1]</code></p>

<p>How do I select last OPTION?</p>

<p>I am using Scrapy Framework.</p>

<p>You have an extra <code>/</code> before the <code>[</code> making the XPath expression <em>invalid</em>. Remove it:</p>

<pre><code>//*[@id="quantity"]/option[last()-1]
</code></pre>

<p>Note that you can also solve it using Python/Scrapy:</p>

<pre><code>response.xpath('//*[@id="quantity"]/option')[-1].extract()
</code></pre>

<p>Or, in a <em>CSS selector</em> form:</p>

<pre><code>response.css('#quantity option:last-child').extract_first()
response.css('#quantity option')[-1].extract()
</code></pre>

python scrapy