Created
September 2, 2017 21:02
-
-
Save rsarai/e7470df8cce3745d539b2f27f6552a46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scrapy | |
from scrapy.contrib.pipeline.images import ImagesPipeline | |
from scrapymercado.constants import URLS_AND_NAMES | |
class ScrapymercadoPipeline(ImagesPipeline): | |
def get_media_requests(self, item, info): | |
for image_url in item.get('image_urls', []): | |
yield scrapy.Request(image_url, meta={'filepatch': URLS_AND_NAMES.get(image_url)}) | |
def file_path(self, request, response=None, info=None): | |
return 'full/%s.jpg' % request.meta.get('filepatch') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment