您的位置:首页 > 其它

scrapy框架图片下载注意点

2016-10-13 10:59 162 查看
在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: