title: Requests: Download an excel file using python 3 (invalid literal for int() with base 16)
body: <p>I am new to python, and I am learning to use it to scrape some data for me, but I cannot download an excel file for some reason that I don't understand. I want to download this excel file, when I open this link in any browser it tries to save an excel file:</p>
  
  <p><a href="http://www5.registraduria.gov.co/CuentasClarasPublicoCon2014/Consultas/Candidato/Formulario5xls/2" rel="nofollow noreferrer">http://www5.registraduria.gov.co/CuentasClarasPublicoCon2014/Consultas/Candidato/Formulario5xls/2</a></p>
  
  <p>based on a previous question (see <a href="https://stackoverflow.com/questions/25415405/downloading-an-excel-file-from-the-web-in-python">downloading an excel file from the web in python</a>) I'm using requests in python 3 as this:</p>
  
  <pre><code>import requests, os
  
  
  url="http://www5.registraduria.gov.co/CuentasClarasPublicoCon2014/Consultas/Candidato/Formulario5xls/2"
  
  print("Downloading...")
  requests.get(url)
  output = open('test.xls', 'wb')
  output.write(resp.content)
  output.close()
  print("Done!")
  </code></pre>
  
  <p>I think that the problem is not with the part of the code that writes the data since the test.xls is being created but as an empty file. the requests.get gives me the following error (followed bu several more):</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 417, in _update_chunk_length
      self.chunk_left = int(line, 16)
  ValueError: invalid literal for int() with base 16: b''
  </code></pre>
  
  <p>I also tried using the urllib but still failed.</p>