Accessing Meal Swipe Information (Python)

The app "The Ropes" for Dartmouth displays the swipes remaining and DBA on your account if given your ManageMyID information. I was curious as to how easily that could be replicated in Python, and then in my own app.

In Python, it's relatively easy, though it took me a while to figure out where I was going wrong. It turns out that when the website is generated, JavaScript code runs to insert a hidden input into the form, with a session token variable called "__sesstok". However, this is also generated in the HTML when the PHP is accessed, and doesn't change until the form is submitted. Luckily, this means that with a simple GET request, you can extract the session token, and use it in a POST to the same login with your credentials.

The source code (with main details blocked out) can be viewed here, in my GitHub account.