I want to check if an image exists on the given URL using python(urllib2). For example how do I check that an image exists on this url.
https://www.example.com/image.png
If not exist then now its retriving a html content, its not good, i want to check that url has an image then only execute the next code. Sample Code,
try: image = urllib2.urlopen(URL).read() image_base64 = base64.encodestring(image) Set image if exist except: default image set