items也引入了
obj_item = XiaohuaItem()
obj_item['name'] = name
obj_item['src'] = src
yield obj_item
#settings文件
ITEM_PIPELINES = {
'spider.pipelines.SpiderPipelineXH': 100
}
#piplines 文件
from scrapy.pipelines.images import ImagesPipeline
import scrapy
class SpiderPipelineXH(ImagesPipeline):
ptinr('这里有输出')
def get_media_requests(self, item, info):
print(item) #没有输出
yield scrapy.Request(item['src'])
def item_completed(self, results, item, info):
print(results)
return item
当你使用图片管道时,需要设置 IMAGES_STORE
参考https://scrapy-chs.readthedocs.io/zh_CN/0.24/topics/images.html
python没有重载。
谢谢,总算有人回复了,我回家试试。我记得我写那个配置了。你用yeild Request成功下载照片了吗