from scrapy.pipelines.images import ImagesPipeline
import scrapy
class ImgspiderdemoPipeline(ImagesPipeline):
def get_media_requests(self, item, info):
print(990)
lists=len(item["image_urls"])
for index in lists:
url=item["image_urls"][index]
name=item["imagename"][index]
yield scrapy.Request(url=url,meta={"name":name})
def file_path(self, request, response=None, info=None):
print(response.meta["name"])
return response.meta["name"]+".jpg"
def process_item(self, item, spider):
print(item["imagename"][0])
return item
ITEM_PIPELINES = {
'imgspiderdemo.pipelines.ImgspiderdemoPipeline': 800,
}
重写了插件,没报错但好像没效果没有执行,图片没下载谁知道怎么回事
下载文件、图片需要安装 Pillow