0
votes

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.

2

2 Answers

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

With a Scrapy response:

response.css('span.m-icon').xpath('../@href')