在setting中的設置:
ITEM_PIPELINES = {
'beautyImg.pipelines.BeautyimgPipeline': 500,
'scrapy.pipelines.images.ImagesPipeline':1
}
IMAGES_URLS_FIELD = 'IMG_URL'
IMAGES_STORE = r'.' #下載圖片存放目錄。r"."爲工程項目目錄
item中格式:
try:
img_url = div.xpath('div[@class="personal-info"]/div[@class="pic-word"]/div/a/img/@src')[0].extract()
item['IMG_URL'] = ["http:" + img_url] #要以list的形式放到item中
print item['IMG_URL']
except Exception,e:
print "ERROR:",e
yield item