Fabio Fabio - 16 days ago 6
Python Question

Python scraping xpath get <a> with specific <span>

I'm using Scrapy to get some data from a website.
I have the following list of links:

<li class="m-pagination__item">
<a href="?isin=IT0000072618&lang=it&page=9">10</a>
</li>
<li class="m-pagination__item">
<a href="?isin=IT0000072618&lang=it&page=1">
<span class="m-icon -pagination-right"></span>
</a>




I want to extract the href attribute only of the 'a' element that contains the span class="m-icon -pagination-right".

I've been looking for some examples of xpath but I'm not an expert of xpath and I couldn't find a solution.

Thanks.

Answer
//a[span/@class = 'm-icon -pagination-right']/@href