Spider must return Request, BaseItem, dict or None, got 'set'

{} is notation to define a set in python, or a dictionary. Depends on the values you provide inside of the curly brackets. If it's a list {a,b,c,d} <- that's a set, if it's key to value {a:b, c:d} <- that's a dict.

You yield a set in this line:

yield {
    ImgData(image_urls=[url.css('img::attr(src)').extract()])
}

I assume you want to yield a dictionary?

yield {
    'images': ImgData(image_urls=[url.css('img::attr(src)').extract()]),
}

Pass a list of urls to the pipeline.

 def parse (self, response):
     images = ImgData()
     images['image_urls']=[] 
     for url in response.css('div.products-grid div.grid-product'):
         images['image_urls'].append(url.css('img::attr(src)').extract_first())
     yield images

Tags:

Python

Scrapy