参考 : https://www.jianshu.com/p/6c8d2730d088

https://docs.scrapy.org/en/latest/topics/item-pipeline.html#writing-your-own-item-pipeline

import scrapy

import requests

import os

class MeinvSpider(scrapy.Spider):
     name = "get_meinv"

start_urls = [
         'https://www.du114.com/',
     ]

def parse(self, response):

dir_path = '%s/%s' % (".", self.name)

if not os.path.exists(dir_path):
             os.makedirs(dir_path)

for imggroup in response.css('div.Column-picBox'):
             imgset = imggroup.css('ul>li img::attr("src")')
             for image_url in imgset.extract():

print("image_url=%s" % image_url)

us = image_url.split('/')[3:]
                 image_file_name = '_'.join(us)
                 file_path = '%s/%s' % (dir_path, image_file_name)

if os.path.exists(file_path):
                     continue

with open(file_path, 'wb') as handle:
                     response = requests.get(image_url, stream=True)
                     for block in response.iter_content(1024):
                         if not block:
                             break

handle.write(block)

最新文章

  1. git下载自己项目到本地
  2. Android数据缓存
  3. 操作AppConfig.xml中AppSettings对应值字符串
  4. 小型工厂企业网站究竟该怎么做好SEO优化,从而带来更多订单?
  5. QA:java.lang.RuntimeException:java.io.FileNotFoundException:Resource nexus-maven-repository-index.properties does not exist.
  6. Android中显示网页的多种方式
  7. Nginx配置性能优化(转)
  8. POJ 2891 扩展欧几里德
  9. Java编程中时区和时间相关的问题
  10. apache禁止公网IP访问的配置
  11. IIS环境下部署项目
  12. phpunit实践笔记
  13. SoapUI模拟REST MockService
  14. WebForm AnyWay
  15. Windows DIB文件操作具体解释-4.使用DIB Section
  16. (zhuan) Using convolutional neural nets to detect facial keypoints tutorial
  17. MDK 的编译过程及文件类型全解
  18. 基于nginx-rtmp-module模块实现的HTTP-FLV直播模块(nginx-http-flv-module)
  19. Android-自定义TabHost
  20. C++ STL 一般总结(转载)

热门文章

  1. ipa企业签名
  2. 阿里巴巴JAVA开发手册
  3. Springboot项目配置druid数据库连接池,并监控统计功能
  4. GIL:全局解释器锁 VS 用户程序锁
  5. Django 简介
  6. 初识服务发现及Consul框架的简单使用
  7. java8 Lambda表达式的新手上车指南(1)--基础语法和函数式接口
  8. 采用ADM2483磁隔离器让RS485接口更简单更安全
  9. SQL Server的JOIN是支持使用小括号修改执行顺序的
  10. LOJ2396 JOISC2017 长途巴士 斜率优化