我尝试在此site上获得分页链接,但无济于事。
蜘蛛:
for next_page in response.css('._3ZWfj::attr(href)').getall():
if next_page is not None:
next_page = response.urljoin(next_page)
yield scrapy.Request(next_page, callback=self.profile_link)
html:
<nav class="_2uKgC" aria-label="Page navigation" data-qa-target="pagination">
<p>Page 1 of 660</p>
<ul>
<li class="ktQcN"><span class="CxgVm _3ZWfj"><svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" class="USD7b MBqXj _3NE5i _2bkBT" role="img" aria-label="Previous page" focusable="false"><polyline fill="none" stroke-linecap="round" points="16 20 8 12 16 4"></polyline></svg></span></li>
<li><span class="HWGOs _3ZWfj">1</span></li>
<li class="_35eJJ _2Sm6k"><span class="CxgVm _3ZWfj">...</span></li>
<li class=""><a href="/usearch?what=Acupuncture&entityCode=PS158&distances=National&pageNum=2&sort.provider=bestmatch" class="_3ZWfj" aria-label="Page 2">2</a></li>
<li class=""><a href="/usearch?what=Acupuncture&entityCode=PS158&distances=National&pageNum=3&sort.provider=bestmatch" class="_3ZWfj" aria-label="Page 3">3</a></li>
</ul>
</nav>