title: Python 3 - use urllib to run .jsp script and retrieve results
body: <p>I have a csv file that is created everytime I run a .jsp file on a Tomcat server. When done manually I click on a link "servers.jsp" and a file "server_list.csv" starts downloading.</p>
  
  <p>I would like to do this in a Python v3 script so I can iterate over the results and automate the process.</p>
  
  <p>here is my code to send a POST to the server, pass auth values in the url and receive the generated .csv</p>
  
  <pre><code>import urllib.request
  
  link = "https://tomcat.server.org:8443/html/scripts/servers.jsp"
  userpass = {'pass': '12345', 'user': 'admin'}
  
  data = urllib.parse.urlencode(userpass)
  data = data.encode('utf-8') 
  req = urllib.request.Request(link, data)
  resp = urllib.request.urlopen(req)
  respData = resp.read()
  
  saveFile = open(Myfile.csv,'w')
  saveFile.write(str(respData))
  saveFile.close()
  </code></pre>
  
  <ul>
  <li>A file is indeed created but it is not the full file only the first row( or parts of) of what the file should contain. Why doesn't the whole file get downloaded ?</li>
  <li>How can i print as a string the value of <code>urllib.request.urlopen(req)</code> ?</li>
  </ul>
  
  <p>Note: I can not use any module that does not come with the default distro of Python 3</p>