I'm trying to figure out the best way to click next page button in www.booking.com hotel list and to continue spider running.
When inspected button:
<li class="nextpage"
a href="/bigcity/offset=15"class=gotopage_2"
</li>
working code for single page:
import scrapy
from ..items import BookItem
class BookSpiderSpider(scrapy.Spider):
name = "book_spider"
start_urls = (
'https://www.booking.com/smallcity/offset=10',
)
def parse(self, response) :
items = BookItem()
title_name = response.css('span.sr-hotel__name::text').extract()
items['title_name'] = title_name
yield items
a href and class everytime changes when button is being clicked
So I'm guessing python code should find the button then take different href replace it with existing url and go there