samedi 28 février 2015

Can't Extract Image From PHP in Python

I'm trying to build a program in Python that will scrape a website for an image and download it, but the website returns this link:


http://ift.tt/1LY8jS1


Which doesn't have a *.jpg or *.png extension. So when I try to use the following code:



import urllib , urllib2, os , sys , time
img = urllib.urlopen("http://ift.tt/1LY8jS1").read()
hand0 = open("test.jpg" , "w")
hand0.write(img)
hand0.close()


It writes an image that looks like this:


http://ift.tt/1LY8ixz


Does anyone know what's going wrong?


Thanks, Ted


Aucun commentaire:

Enregistrer un commentaire