After scrambling together information about this from all over the internet (but mostly the python docs) I found out how to do it.
- import urllib2
-
request = urllib2.Request(image url)
-
try: response = urllib2.urlopen(request)
-
except URLError, err:
-
pass #here will come code that is irrelevant to my problem
-
c_image = response.read()
-
file = open(desired filename and location, "wb")
-
file.write(c_image)
-
file.close()
Still thanks to anyone who was trying to help, but wasn't fast enough.
For anyone trying to learn something from this: I'm using writing mode "wb" to write the file in binary mode, as images aren't ASCII files, and can't be written in the normal writing mode.