title: How to login to a website with python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module">How to “log in” to a website using Python’s Requests module?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm programming an application in python 3.2.3, and I don't know how to login to a website. I need to login... and save cookies(I think), but everything I tried doesn't work. </p>
  
  <p>I had try <a href="http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file" rel="nofollow noreferrer">Requests</a>, but no luck. My webpage is running on localhost (it's just simple login form).</p>
  
  <pre><code>FORM:
      &lt;form method="post" action=""&gt;
              &lt;input type="text" name="uname" placeholder="Uporabnisko ime:"/&gt;
              &lt;input type="password" name="password" placeholder="Geslo:"/&gt;
              &lt;input type="submit" value="Send"/&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Python:</p>
  
  <pre><code>import requests
  payload = {'uname': 'name', 'password': 'pswd123'}
  r = requests.post('http://localhost/python', data=payload)
  </code></pre>
  
  <p>This do nothing. How to post name and username.. 
  Thanks for reply. </p>