Renaming downloaded images in Scrapy 0.24 with content from an item field while avoiding filename conflicts?

后端 未结 2 841
清酒与你
清酒与你 2020-12-24 09:47

I\'m attempting to rename the images that are downloaded by my Scrapy 0.24 spider. Right now the downloaded images are stored with a SHA1 hash of their URLs as the file name

2条回答
  •  梦毁少年i
    2020-12-24 10:33

    Since the URL hash will make sure you'll end up with a unique identifier, you could perhaps just write separately to a file the item's value and the URL hash.

    After all is done, you can then just loop over this file and do the renaming (and using a Counter dictionary to make sure you rename them with a number appended based on how many Items with an equal value).

提交回复
热议问题