我正在尝试使用scrapy下载图像,但返回以下错误:
raise NotSupported("Response content isn't text")
scrapy.exceptions.NotSupported: Response content isn't text
2018-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 myitem
def parseImages(self, response):
for elem in response.xpath("//img"):
img_url = elem.xpath("@src").extract_first()
yield ImageItem(image_urls=[img_url])
项目.py
class ImageItem(scrapy.Item):
image_urls = scrapy.Field()
images = scrapy.Field()
我需要在 yield 命令中进行一些调整吗?
aluckdog
相关分类