title: Login and get HTML file using python
body: <p>Hey I'm trying to login to a website and get the html of the webpage after the login. And can't figure out how to do it with python. Using python 2.7. Need to fill out the html forms on this website:</p>
  
  <p></p>
  
  <p>'user'= 'magaleast' and 'password' = '1181' (real login details that are useless to me). Then the website redirects the user to an authentication page and when its done it goes to the page i need.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT:
  trying this code:</p>
  
  <pre><code>from mechanize import Browser
  import cookielib
  br = Browser()
  br.open("http://www.shiftorganizer.com/")
  
  
  cj = cookielib.LWPCookieJar()
  br.set_cookiejar(cj)
  
  # Browser options
  br.set_handle_equiv(True)
  br.set_handle_gzip(True)
  br.set_handle_redirect(True)
  br.set_handle_referer(True)
  
  # You need to spot the name of the form in source code
  br.select_form(name = "user")
  # Spot the name of the inputs of the form that you want to fill, 
  # say "username" and "password"
  br.form["user"] = "magaleast"
  br.form["password"] = "1181"
  
  response = br.submit()
  print response.read()
  </code></pre>
  
  <p>but i get:</p>
  
  <pre><code>     &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
  
  &lt;title&gt;ShiftOrganizer סידור עבודה בפחות משניה&lt;/title&gt;
  
      &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  
  
  
  &lt;script type="text/javascript"&gt;
  
  var emptyCompany=1
  
  function subIfNewApp()
  
  {
  
      if (emptyCompany){
  
          document.authenticationForm.action = document.getElementById('userName').value + "/authentication.asp"
  
      } else {
  
          document.authenticationForm.action = document.getElementById('Company').value + "/authentication.asp"
  
      }
  
      document.authenticationForm.submit()
  
  }
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  
      &lt;body onload="subIfNewApp()"&gt;
  
      &lt;form name="authenticationForm" method="post" action=""&gt;
  
          &lt;input type="hidden" name="userName" id="userName" value="magaleast" /&gt;
  
          &lt;input type="hidden" name="password" id="password" value="1181" /&gt;
  
          &lt;input type="hidden" name="Company" id="Company" value="שם חברה" /&gt;
  
          &lt;/form&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>is js the problem? because it stops in the authentication part again..?</p>