I am able to download images through scrapy in to the "Full" folder but I need to make the name of the destination folder dynamic, like full/session_id
, every time scrapy runs.
Is there any way to do this?
I am able to download images through scrapy in to the "Full" folder but I need to make the name of the destination folder dynamic, like full/session_id
, every time scrapy runs.
Is there any way to do this?
I have not worked with the
ImagesPipeline
yet, but following the documentation, I'd overrideitem_completed(results, items, info)
.The original definition is:
This should give you the result sets of the downloaded images including the path (seems there can be many images on one item).
If you now change this method in a subclass to move all files before setting the path, it should work as you want. You could set the target folder on your item in something like
item['session_path']
. You'd have to set this setting on each item, before returning/yielding your items from the spider.The subclass with overriden method could then look like this:
Even nicer would be to set the desired session path not in the
item
, but in the configuration during your scrapy run. For this, you would have to find out how to set config while the application is running and you'd have to override the constructor, I think.