python scrapy爬虫爬取图片简易方法,使用Images模块
2017-08-21 20:15
671 查看
使用scrapy的images模块,必须先安装pillow
$ pip install pillow
在settings.py中添加
只需添加##### ###中的内容即可。
当然我们也可以存储图片的大小。
# IMAGES_THUMBS = {
# 'small': (50, 50),
# 'big': (270, 270),
# }
$ pip install pillow
在settings.py中添加
# -*- coding: utf-8 -*- # Scrapy settings for topgoods project # # For simplicity, this file contains only the most important settings by # default. All the other settings are documented here: # # http://doc.scrapy.org/en/latest/topics/settings.html # BOT_NAME = 'topgoods' SPIDER_MODULES = ['topgoods.spiders'] NEWSPIDER_MODULE = 'topgoods.spiders' DOWNLOADER_MIDDLEWARES = { 'scrapy.contrib.downloadermiddleware.httpproxy.HttpProxyMiddleware':301, } ###########################################################################3 ITEM_PIPELINES = {'scrapy.pipelines.images.ImagesPipeline': 1} IMAGES_URLS_FIELD = 'file_urls' ############file_urls是指item的key值 IMAGES_STORE = r'.' ####存储位置,此处为本文件夹下存储 # IMAGES_THUMBS = { ###########定义图片存储时的大小 # 'small': (50, 50), # 'big': (270, 270), # } ########################################################################### LOG_FILE = "scrapy.log"
只需添加##### ###中的内容即可。
当然我们也可以存储图片的大小。
# IMAGES_THUMBS = {
# 'small': (50, 50),
# 'big': (270, 270),
# }
相关文章推荐
- Python使用爬虫抓取美女图片并保存到本地的方法【测试可用】
- Python3网络爬虫:Scrapy入门之使用ImagesPipline下载图片
- Python使用Scrapy爬虫框架全站爬取图片并保存本地的实现代码
- 讲解Python的Scrapy爬虫框架使用代理进行采集的方法
- python网络爬虫之使用scrapy爬取图片
- 使用简易Python爬虫下载百度贴吧图片
- [爬虫入门]Python中使用scrapy框架实现图片爬取
- Python使用爬虫爬取静态网页图片的方法详解
- 讲解Python的Scrapy爬虫框架使用代理进行采集的方法
- [Python]使用Scrapy爬虫框架简单爬取图片并保存本地
- Python爬虫框架Scrapy安装使用步骤
- python commands包不支持windows环境与如何在windows下使用的简易方法
- python使用正则表达式分析网页中的图片并进行替换的方法
- python学习:urllib库学习:制作简易爬虫下载图片
- Python爬虫框架Scrapy 学习笔记 5 ------- 使用pipelines过滤敏感词
- 【用Python写爬虫】获取html的方法【一】:使用urllib
- 【用Python写爬虫】获取html的方法【二】:使用pycurl
- 【用Python写爬虫】获取html的方法【三】:使用cPAMIE
- Python中使用Flask、MongoDB搭建简易图片服务器
- python简易爬虫来实现自动图片下载