I'm using scrapy with scrapy-selenium and I'm unable to handle pagination because href contains only # symbol.
class PropertyScraperSpider(scrapy.Spider):
name = 'property_scraper'
allowed_domains = ['www.samtrygg.se']
def start_requests(self):
yield SeleniumRequest(
url='https://www.samtrygg.se/RentalObject/NewSearch',
wait_time=3,
headers=self.headers,
callback=self.parse_links
)
def parse_links(self, response):
cards = response.xpath("//div[@class='owl-carousel owl-theme show-nav-hover']/div/a")
for card in cards:
link = card.xpath(".//@href").get()
print('\n\n:link',len(link))
yield SeleniumRequest(
url= link,
wait_time=3,
headers=self.headers,
callback=self.parse,
)
next_page = response.xpath("//a[@id='next']/@href").get()
print('\n\n\nNEXT_PAGE',next_page)
if next_page:
absolute_url = f'https://www.samtrygg.se/RentalObject/NewSearch{next_page}'
yield SeleniumRequest(
url=absolute_url,
headers=self.headers,
wait_time=3,
callback=self.parse_links
)
def parse(self,response):
pass
I need help with this pagination issue. how can I handle it? Any help would be highly appreciated.


