I am trying to log on to a website using python and the requests library. I am having some difficulties getting the authenticity keys to work, as they are not specified in the format usually found in other questions here. The HTML markup for the login page is given here:
<html>
<head>
<title>OnLogger</title>
<link rel="stylesheet" href="/jottonia/stylesheet.css" type="text/css">
</head>
<body bgcolor="#FFFFFF">
<img src="/jottonia/gfx/midaslogo.gif">
<p> </p>
<h1>Log in to Jottonia</h1>
<form action="OnLogger" method="POST">
<table class="formtable">
<tbody>
<tr>
<th>Username (e-mail)</th>
<td>
<input size="10" name="email" value="" data-keeper-edited="yes" data-keeper-lock-id="k-iw0hz0yr8pm">
<keeper-lock id="k-iw0hz0yr8pm" style="filter: grayscale(100%); top: 209.156px; left: 367px; z-index: 1; visibility: hidden;"></keeper-lock>
</td>
</tr>
<tr>
<th>Password</th>
<td>
<input type="PASSWORD" name="password" size="10" data-keeper-lock-id="k-5db0syl9lsj" data-keeper-edited="yes">
<keeper-lock id="k-5db0syl9lsj" style="filter: grayscale(100%); top: 240.156px; left: 367px; z-index: 1; visibility: hidden;"></keeper-lock>
</td>
</tr>
</tbody>
</table>
<p><input type="SUBMIT" value="Enter" name="button"> <input type="SUBMIT" value="Mail me the password again" name="button"></p>
</form>
<style>input[data-keeper-lock-id="k-5db0syl9lsj"]:not(:hover) ~ keeper-lock#k-5db0syl9lsj {animation-name: hide-lock; animation-duration: .5s;}
input[data-keeper-lock-id="k-iw0hz0yr8pm"]:not(:hover) ~ keeper-lock#k-iw0hz0yr8pm {animation-name: hide-lock; animation-duration: .5s;}
</style>
</body>
</html>
The interesting regions are <input size="10" name="email" value="" data-keeper-edited="yes" data-keeper-lock-id="k-iw0hz0yr8pm">
and <input type="PASSWORD" name="password" size="10" data-keeper-lock-id="k-5db0syl9lsj" data-keeper-edited="yes">
.
I am assuming that the data-keeper-lock-id is some form of authenticity key, and this key is indeed randomly generized each time I reload the page. However, the keys for the email and password are different, and the don't follow the "name"/"value" format that I've seen before. Extracting the values I should be able to do with regular expressions and some clever indexing, but how should I give this when using requests.post? My login info is stored in a dictionary:
myemail = "my@email.com"
mypassword = "1234"
login_info = {"email": myemail, "password": mypassword}
But I thought that requests.post looks for the "name" tag in order to pass the login info?