I was using scrapy for web scraping, I can grab all elements but my target is to get all the names having reviews greater than 50 , I don't know where I am lacking
import scrapy
class TripadSpider(scrapy.Spider):
name = 'tripad'
allowed_domains = ['www.tripadvisor.in']
start_urls = ['https://www.tripadvisor.in/Restaurants-g304554-c33-Mumbai_Maharashtra.html']
first = 'https://www.tripadvisor.in/'
def parse(self, response):
for i in response.xpath("//div[@class='_2Q7zqOgW Vt o']"):
rating = str(i.xpath(".//span[@class='w726Ki5B']/text()").get())
if rating >= '50':
title = i.xpath(".//a[@class='_15_ydu6b S5 H4 Cj b']/text()").getall()
yield {
'title':title,
'rating':rating
}
elif rating == 'None':
continue
next_page = response.xpath("//a[@class='nav next rndBtn ui_button primary taLnk']/@href").get()
if next_page:
sequence = (self.first,next_page)
nexturl = ''.join(sequence)
yield scrapy.Request(url=nexturl,callback=self.parse)
can somebody assist me