Reputation: 63
I'm building a scraper for this page I want to follow to next page after making first page work and after setting auto throttle and download speed to be gentle and I tried using:
next_page = response.xpath('//div[@class="global-pagination"]/a[@class="next"]/@href').get()
if next_page is not None:
yield response.follow(next_page, self.parse)
Problem is that href in that class is # and basically it opens same page again. How do I make it work?
Upvotes: 0
Views: 135
Reputation: 976
If you take a look at your browser developer tool you will see when you go to other pages data loads from loadresult. furthermore by searching in Form Data you'll see there is a field named page
have a value of the page you requested which you can request any other page by changing it in your formdata in FormRequest
.
from scrapy.http import FormRequest
FormRequst(url=url, formdata=formdata={'page': <page number>}, callback=<parse method>)
Upvotes: 1