quotes_spider not working.
Code is executing right, but DEBUG doesn’t show the names of saved files on terminal and files are not saved as well.
My code:
import scrapy
class QuotesSpider(scrapy.Spider):
name = “quotes_spider”
def start_request(self):
urls = [
"http://quotes.toscrape.com/page/1/",
"http://quotes.toscrape.com/page/2"
]
# Generator Function
for url in urls:
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, response):
page_id = response.url.split("/")[-2]
filename = "quotes-%s"%page_id
with open(filename, 'wb') as f:
f.write(response.body)
self.log('Saved File -> %s'%filename)