title: How to download image using requests
body: <p>I'm trying to download and save an image from the web using python's <code>requests</code> module.</p>
  
  <p>Here is the (working) code I used:</p>
  
  <pre><code>img = urllib2.urlopen(settings.STATICMAP_URL.format(**data))
  with open(path, 'w') as f:
      f.write(img.read())
  </code></pre>
  
  <p>Here is the new (non-working) code using <code>requests</code>:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Can you help me on what attribute from the response to use from <code>requests</code>?</p>