我正在尝试使用scrapy下载图像,但返回以下错误:raise NotSupported("Response content isn't text")scrapy.exceptions.NotSupported: Response content isn't text2018-11-30 14:36:09 [scrapy.core.scraper] ERROR: Spider error processing <GET https://www.example.bla/39307b2103.jpg> 这是我正在使用的相应代码:...myitem['i10_img'] = 'https://www.example.de' + response.css("#fullscreen_img::attr(src)").extract_first()[2:]yield scrapy.Request(myitem['i10_img'],callback=self.parseImages, meta={'item': myitem})return myitemdef parseImages(self, response): for elem in response.xpath("//img"): img_url = elem.xpath("@src").extract_first() yield ImageItem(image_urls=[img_url])项目.pyclass ImageItem(scrapy.Item):image_urls = scrapy.Field()images = scrapy.Field()我需要在 yield 命令中进行一些调整吗?
1 回答

aluckdog
TA贡献1847条经验 获得超7个赞
我认为您误解了图像管道的工作原理。
您正在尝试创建对图像 url 本身的请求并将其解析为 HTML。
相反,您应该简单地将图像 url 添加到image_urls
of myitem
(就像您尝试在 中所做的那样parseImages
)。
添加回答
举报
0/150
提交
取消