Logging into a website with Python using requests, how do you resolve what needs to be sent?
<p>I'm using the following script to attempt a site login with the requests library for this website: <a href="https://cas.shopatron.com/cas/login" rel="nofollow">https://cas.shopatron.com/cas/login</a></p>

<p>However, I always seem to get the login page as the response, so I'm thinking my payload is off. How do I determine what's required in the payload? Or am I missing something else here?</p>

<p>Script:</p>

<pre><code>import requests
from lxml import html




login_url = 'https://cas.shopatron.com/cas/login'
authd_url = 'https://www.shopatron.com/rtl/'
name = '*****'
password = '*****'



payload = {
    "username": name, 
    "password": password,
    "submit" : "Submit",
    "lt": "LT-1426788-q3xOkNQDdGN7wB0AJMAKkegYKNosBN-i-f1229b28",
    "execution": "e12s1",
    "_eventId": "submit"
}


session_requests = requests.session()


result = session_requests.get(login_url)

tree = html.fromstring(result.text)


result = session_requests.post(
    login_url, 
    data = payload, 
    headers = dict(referer=login_url)
)

resultauthd = session_requests.get(authd_url)

print resultauthd
print resultauthd.encoding
print resultauthd.content
print resultauthd.headers
</code></pre>