我正在嘗試使用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
提交
取消