dimanche 31 juillet 2016

Python: Given a link, how to save locally if the link is an image and do not save if it is not an image?

I am currently using

import urllib

urllib.urlretrieve("http://www.digimouth.com/news/media/2011/09/google-logo.jpg", "local-filename.jpg")

Is there a way to see if the link contains a pic or not, if not then no need to download, if so, then download.

Thanks!

Aucun commentaire:

Enregistrer un commentaire