I am missing something in my code.
Kindly have a look
98 % accuracy in Scrape a book Store challenge
import scrapy
class BookSpider(scrapy.Spider):
name = "Book_Crawler"
def start_requests(self):
urls = [
"http://books.toscrape.com/catalogue/page-1.html"]
for url in urls:
yield scrapy.Request(url = url , callback = self.parse)
def parse(self , response):
for q in response.css('article.product_pod'):
image_url = q.css('div.image_container a img::attr(src)').get()
title = q.css('h3 a::attr(title)').get()
price = q.css('div.product_price p.price_color::text').get()
yield{
'image_url' : image_url,
'book_title' : title,
'product_price' : price
}
next_page = response.css('ul.pager li.next a::attr(href)').get()
if next_page is not None:
next_page = response.urljoin(next_page)
yield scrapy.Request(next_page , callback=self.parse)
Hey @mananaroramail, your code is completely fine, actually the solution csv, did not contain “…/” in “…/media/cache/5d/72/5d72709c6a7a9584a4d1cf07648bfce1.jpg” for the first 20 rows. But it contains “…/” for all the rest 980 rows. Actually “…/” should be present, so informed the backent team, will be updated soon.
Hope this cleared your doubt.
Plz mark the doubt as resolved if you find it so in my doubts section. 