title: How to download image using Scrapy?
body: <p>I am newbie to scrapy. I am trying to download an image from <a href="http://www.shopclues.com/canon-powershot-sx410-is-2.html" rel="nofollow">here</a>. I was following <a href="https://doc.scrapy.org/en/latest/topics/media-pipeline.html" rel="nofollow">Official-Doc</a> and <a href="http://www.pyimagesearch.com/2015/10/12/scraping-images-with-python-and-scrapy/" rel="nofollow">this article</a>. <br></p>
  
  <p>My settings.py looks like:</p>
  
  <pre><code>BOT_NAME = 'shopclues'
  
  SPIDER_MODULES = ['shopclues.spiders']
  NEWSPIDER_MODULE = 'shopclues.spiders'
  
  ROBOTSTXT_OBEY = True
  
  ITEM_PIPELINES = {
      'scrapy.contrib.pipeline.images.ImagesPipeline':1
  }
  
  IMAGES_STORE="home/pr.singh/Projects"
  </code></pre>
  
  <p><br>
  and <code>items.py</code> looks like: </p>
  
  <pre><code>import scrapy
  from scrapy.item import Item
  
  class ShopcluesItem(scrapy.Item):
      # define the fields for your item here like:
      # name = scrapy.Field()
      pass
  
  class ImgData(Item):
      image_urls=scrapy.Field()
      images=scrapy.Field()
  </code></pre>
  
  <p>I think both these files are good. But I am unable to write correct spider for getting the image. I am able to grab the image URL but don't know how to store image using <code>imagePipeline</code>.<br>
  My spider looks like:</p>
  
  <pre><code>from shopclues.items import ImgData
  import scrapy
  import datetime
  
  
  class DownloadFirstImg(scrapy.Spider):
      name="DownloadfirstImg"
      start_urls=[
      'http://www.shopclues.com/canon-powershot-sx410-is-2.html',
      ]
  
      def parse (self, response):
          url= response.css("body div.site-container div#container div.ml_containermain div.content-helper div.aside-site-content div.product form#product_form_83013851 div.product-gallery div#product_images_83013851_update div.slide a#det_img_link_83013851_25781870")
  
          yield scrapy.Request(url.xpath('@href').extract(),self.parse_page)
  
          def parse_page(self,response):
              imgURl=response.css("body div.site-container div#container div.ml_containermain div.content-helper div.aside-site-content div.product form#product_form_83013851 div.product-gallery div#product_images_83013851_update div.slide a#det_img_link_83013851_25781870::attr(href)").extract()
  
              yield {
              ImgData(image_urls=[imgURl])
              }
  </code></pre>
  
  <p>I have written the spider following <a href="http://www.pyimagesearch.com/2015/10/12/scraping-images-with-python-and-scrapy/" rel="nofollow">this-article</a>. But I am not getting anything. I run my spider as <code>scrapy crawl DownloadfirstImg  -o img5.json
  </code> but I am not getting any json nor any image?<br>  Any help on How to grab image if it's url is known. I have never worked with python also so things seem much complicated to me. Links to any good tutorial may help. TIA</p>