Regarding accuracy in the book challenge

Below is my code. I have already written header(image_url,book_title,product_price) in my csv file.

import scrapy

class QuotesSpider(scrapy.Spider):
name = “quotes”

def start_requests(self):
    urls = ["http://books.toscrape.com/"]
    for url in urls:
        yield scrapy.Request(url=url, callback=self.parse)

def parse(self, response):


    with open("books3.txt","a") as file:
        #file.write("image_url,book_title,product_price\n")
        books=response.css("article.product_pod")
        for book in books:
            title='"'+book.css("h3 a").attrib["title"]+'"' # quotes added to include comma in title
            #title='"'+book.css("h3 a::text").get()+'"'
            prices=book.css("div.product_price p.price_color::text").get()
            image_url=book.css("a img").attrib["src"]

            file.write(image_url+","+title+",Â"+prices+"\n") # submitted both files which included  as given in sample and without it
        next_page = response.css('li.next a::attr(href)').get()
        if next_page is not None:
            yield response.follow(next_page, callback=self.parse)

if there is problem in the indentation of the code, click the link : https://drive.google.com/file/d/1B6x2vZ_fpgDOOqQ3By-QlS7tYBMKscRR/view?usp=sharing

Hey @saksham_105, share the csv created by your code after saving it on google drive and sharing the link here, i will directly check it with the backend system.

Below is the link for google drive for all my 3 submissions each with 13% accuracy
https://drive.google.com/drive/folders/1qnSJB9J_Bz94fKrTdt7tEUW8rYYZrp-w?usp=sharing

Hey @saksham_105, extremely sorry for delay at my end, the error is due to the fact that, original file contains names as,

['media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg', '"A Light in the Attic"'] 

while your csv contains,

['media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg', 'A Light in the Attic']

Try to correct it your self, and to check that read the csv generated by you line by line perform split on basis of space and then see if its same as original answer.

Hope this resolved your doubt. :blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.