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.
答案 0 :(得分:1)
//a[span/@class = 'm-icon -pagination-right']/@href
答案 1 :(得分:1)
通过Scrapy回复:
response.css('span.m-icon').xpath('../@href')