title: How to "log in" to a website using Python's Requests module?
body: <p>I am trying to post a request to log in to a website using the Requests module in Python but its not really working. I'm new to this...so I can't figure out if I should make my Username and Password cookies or some type of HTTP authorization thing I found (??). </p>
  
  <pre><code>from pyquery import PyQuery
  import requests
  
  url = 'http://www.locationary.com/home/index2.jsp'
  </code></pre>
  
  <p>So now, I think I'm supposed to use "post" and cookies....</p>
  
  <pre><code>ck = {'inUserName': 'USERNAME/EMAIL', 'inUserPass': 'PASSWORD'}
  
  r = requests.post(url, cookies=ck)
  
  content = r.text
  
  q = PyQuery(content)
  
  title = q("title").text()
  
  print title
  </code></pre>
  
  <p>I have a feeling that I'm doing the cookies thing wrong...I don't know.</p>
  
  <p>If it doesn't log in correctly, the title of the home page should come out to "Locationary.com" and if it does, it should be "Home Page."</p>
  
  <p>If you could maybe explain a few things about requests and cookies to me and help me out with this, I would greatly appreciate it. :D</p>
  
  <p>Thanks.</p>
  
  <p>...It still didn't really work yet. Okay...so this is what the home page HTML says before you log in:</p>
  
  <pre><code>&lt;/td&gt;&lt;td&gt;&lt;img src="http://www.locationary.com/img/LocationaryImgs/icons/txt_email.gif"&gt;    &lt;/td&gt;
  &lt;td&gt;&lt;input class="Data_Entry_Field_Login" type="text" name="inUserName" id="inUserName"  size="25"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;img src="http://www.locationary.com/img/LocationaryImgs/icons/txt_password.gif"&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input  class="Data_Entry_Field_Login"  type="password" name="inUserPass"     id="inUserPass"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>So I think I'm doing it right, but the output is still "Locationary.com"</p>
  
  <p>2nd EDIT:</p>
  
  <p>I want to be able to stay logged in for a long time and whenever I request a page under that domain, I want the content to show up as if I were logged in.</p>