jeudi 13 août 2015

How can I verify this URL directs to an image?

I'm working on a service, written in Python which, at one point, downloads images from given URLs and stores them on a server.

This service does a check of the content-type returned from the URL and only downloads the image if it's content-type is 'image/jpeg', etc.

I recently came up against an interesting problem with the following URL: http://ift.tt/1faJokl

This URL, when opened in a browser, displays an encoded string of some sort.

When used as the 'src' of an image tag, it renders an image.

<html>
<body>
  <img src = 'http://ift.tt/1faJokl'>
</body>
</html>

The content-type of this URL is text/html

Is there any way, in Python, for me to identify that this URL directs to an image which can be used as a 'src'?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire