Search code examples
jsonreddit

A way to see if a reddit image has been deleted


So, I've saved a lot of image links in a JSON file and I'm currently wondering if there is any way to see if any of the links are invalid (that the images have been deleted)?

Once a post is deleted the link gives you this image.


Solution

  • You can fetch the file, calculate its hash and compare it with the hash of 404 image. Since imgur is likely to service same file for all error pages, hash check will do the job.

    Invalid Images

    $ curl https://i.sstatic.net/3pezeE.png | md5sum
    eebc93350a68a64022b7482f460017ba  -
    
    $ curl https://i.sstatic.net/404address.png | md5sum
    eebc93350a68a64022b7482f460017ba  -
    

    Valid Image

    $ curl https://i.sstatic.net/Lv1qU.jpg | md5sum
    6260c61ed80aa569d5cfa5d78440301b  -