import scrapy
class bookscraper(scrapy.Spider):
name=“bookscrape”
start_urls=[“http://books.toscrape.com/”
]
def parse(self,response):
for entity in response.css(‘article.product_pod’):
image_address=entity.css(‘div.image_container img::attr(src)’).get()
title=entity.css(‘h3 a::attr(title)’).get()
price=entity.css(‘p.price_color::text’).get()
yield {'Url':image_address,'Title':title,'Price':price
}
next_page = 'http://books.toscrape.com/'+ response.css('li.next a::attr(href)').get()
if next_page is not None:
yield response.follow(next_page, callback=self.parse)