0

我想将图像存储在不同的文件夹中,文件夹名称为item['title'].
请查看下面的代码,但它不起作用。

  def image_key(self, url,item):
                image_guid = hashlib.sha1(url).hexdigest()
                return '%s/full/%s.jpg' % (item['title'],image_guid)
        def get_media_requests(self, item, info):
                for image_url in item['image_urls']:
                        yield Request(image_url,meta={'id':item['title']})
        def item_completed(self, results, item, info):
                image_paths = [x['path'] for ok, x in results if ok]
                if not image_paths:
                        raise DropItem("item contains no images")
                item['image_paths'] = image_paths
                return item

有任何想法吗?

4

0 回答 0