My quotes.json is empty though i have used same class name
plz help
code is written in https://ide.codingblocks.com/s/140210
Scrapy - Parsing response as JSON
Hey,
Try this code , :
class QuotesSpider(scrapy.Spider): name = "quotes_spider" def start_requests(self): urls = [ 'http://quotes.toscrape.com/page/1/','http://quotes.toscrape.com/page/2/' ] for url in urls: yield scrapy.Request(url=url, callback=self.parse) def parse(self, response): for q in response.css("div.quote"): text = q.css("span.text::text").get() author = q.css("small.author::text").get() tags = q.css("a.tag::text").getall() yield { 'text': text, 'author': author, 'tags' : tags } # self.log("Saved file %s"% filename)
It is working thanks