1

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>&nbsp;</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?

Yoda
  • 463
  • 7
  • 17
  • 1
    Requests is an HTTP library. What you have here is HTML, which is different. If you are trying to automatically log into this website, you would want to be using something else (like selenium or mechanize/beautiful soup). – ivan7707 Feb 22 '18 at 21:32
  • But is not logging in, i.e. making a post request, an HTTP issue? I've seen other questions where the requests library was sufficient to log in to other web pages... See: https://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module – Yoda Feb 23 '18 at 08:35

0 Answers0