title: How do I download images with an https URL in Python 3?
body: <p>I've tried to make a short mass-downloader script in Python to store lists of images locally.</p>
  <p>It works perfectly fine for <code>http</code> image urls, however fails to download any image with an <code>https</code> url. The lines of code in question are:</p>
  <pre><code>import urllib.request
  urllib.request.urlretrieve(url, filename)
  </code></pre>
  <p>For instance,
  <code>https://cdn.discordapp.com/attachments/299398003486097412/303580387786096641/FB_IMG_1490534565948.jpg</code> results in <code>HTTP Error 403: Forbidden</code>, as well as any other <code>https</code> image.</p>
  <p>This leaves me with two questions:</p>
  <ol>
  <li>How am I able to download such an image using Python?</li>
  <li>Why do images even have <code>https</code> urls if they are basically just files?</li>
  </ol>
  <h3>EDIT:</h3>
  <p>Here's the stack trace:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;img_down.py&quot;, line 52, in &lt;module&gt;
      main()
    File &quot;img_down.py&quot;, line 38, in main
      save_img(d, l)
    File &quot;img_down.py&quot;, line 49, in save_img
      stream = read_img(url)
    File &quot;img_down.py&quot;, line 42, in read_img
      with urllib.request.urlopen(url) as response:
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 223, in urlopen
      return opener.open(url, data, timeout)
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 532, in open
      response = meth(req, response)
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 642, in http_response
      'http', request, response, code, msg, hdrs)
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 570, in error
      return self._call_chain(*args)
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 504, in _call_chain
      result = func(*args)
    File &quot;D:\Users\Jan\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, line 650, in http_error_default
      raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 403: Forbidden
  </code></pre>