Scrapy not able to get image url and also not able to download images
<p>I have tried every search result in google and stack overflow solution but i am not able to get the solution.
I am creating a scrapy to extract images please find the code below</p>

<p>My items.py </p>

<pre><code>class MyntraItem(scrapy.Item):
    product_urls=scrapy.Field()
    files=scrapy.Field()
    image_urls=scrapy.Field()
    images = scrapy.Field()
</code></pre>

<p>My settings.py</p>

<pre><code>BOT_NAME = 'hello'

SPIDER_MODULES = ['myntra.spiders']
NEWSPIDER_MODULE = 'myntra.spiders'

FILES_STORE = '/home/swapnil/Desktop/AI/myntra/'
ITEM_PIPELINES = {
   #'myntra.pipelines.SomePipeline': 300,   
   'scrapy.pipelines.images.FilesPipeline': 1,
}
</code></pre>

<p>My first.py</p>

<pre><code>class FirstSpider(CrawlSpider):
    name = "first"
    allowed_domains = ["myntra.com"]
    start_urls = [
        'http://www.myntra.com/men-sports-tshirts-menu?src=tNav&amp;f=Pattern_article_attr%3Astriped',
    ]
    rules = [Rule(LinkExtractor(restrict_xpaths=['//*[@class="product-link"]']),callback='parse_lnk',follow=True)]
    #rules = [Rule(LinkExtractor(allow=['.*']),callback='parse_lnk',follow=True)]

    def parse_lnk(self, response):
        item=MyntraItem()
        item['product_urls']=response.url
        item['files']=response.xpath('//*[@class="thumbnails-selected-image"]/@src')
        item['image_urls']=item['files']
        #print '666666666666666666',item['files']
        return item
</code></pre>

<p>Please help: My intention is to download the images.</p>

<p>Use <strong>ImagesPipeline</strong> instead, and extract the images using <strong>regex</strong>.</p>

<p>In My first.py</p>

<pre><code>item['files']= re.findall('front":\{"path":"(.+?)"', response.body)
</code></pre>

<p>In settings.py</p>

<pre><code>IMAGES_STORE = '/home/swapnil/Desktop/AI/myntra/'

ITEM_PIPELINES = {'myntra.pipelines.SomePipeline': 300,
                  'scrapy.pipelines.images.ImagesPipeline': 1,}
</code></pre>

<p>This would works like a charm.</p>

python image scrapy pipeline