title: using urllib.request to query a url with a range of x-api-key headers
body: <p>I am given a url/port and have to use python 3.8 to obtain a response from a server. The &quot;server&quot; requires an &quot;x-api-key&quot; as a password and will not display information without the correct key. (this is at least what I have gotten from it)</p>
  <p>The key supposedly is between 5500 and 5600.
  I am very new to python and wondering why my code is returning nothing.
  Am I using headers wrong?
  I've been trying things/googling for several hours.</p>
  <pre><code># Alien Signal API listening on http://127.0.0.1:8082
  # Use HTTP GET with x-api-key header to get signal
  # We have narrowed down the key to be in the range of 5500 to 5600
  # Note: The script can timeout if this occurs try narrowing
  # down your search
  #
  import urllib.parse
  import urllib.request
  
  url = &quot;http://127.0.0.1:8082&quot;
  startingKey = 5500
  endingKey = 5600
  hdr = {}
  
  while startingKey &lt;= endingKey:
      hdr = { 'x-api-key' : str(startingKey) }
      req = urllib.request.Request(url, headers=hdr)
      response = urllib.request.urlopen(req)
      response.read()
      startingKey = startingKey + 1
  </code></pre>