download image using requests download image using urllib2 From http://stackoverflow.com/questions/13137817/how-to-download-image-using-requests
#using requests
r = requests.get(settings.STATICMAP_URL.format(**data))
if r.status_code == 200:
img = r.raw.read()
with open(path, 'w') as f:
f.write(img)
#using requests2
r = requests.get(img_url)
with open(img_name,'wb') as f:
f.write(r.content)
#using urllib2
img = urllib2.urlopen(settings.STATICMAP_URL.format(**data))
with open(path, 'w') as f:
f.write(img.read())