Fabio Fabio - 1 month ago 15
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 class="m-pagination__item">
<a href="?isin=IT0000072618&lang=it&page=1">
<span class="m-icon -pagination-right"></span>

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.


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