scrapy框架圖片下載注意點

在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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章