Last active
August 3, 2016 04:50
-
-
Save tdeck/2cdb88af83bbd2cb67a7cda81b22694d to your computer and use it in GitHub Desktop.
Script to demonstrate logging into WebSTAC using Python Mechanize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
import getpass | |
# Get through the "Log in" button | |
br = mechanize.Browser() | |
br.open("https://acadinfo.wustl.edu/WebSTAC_init.asp") | |
br.select_form(name="form0") | |
br.submit() | |
# Get past the onload redirect page | |
br.open("Private/WebSTAC.asp") | |
# Submit the login form | |
br.select_form(name="form1") | |
br["ucWUSTLKeyLogin$txtMUsername"] = raw_input("Username: ") | |
br["ucWUSTLKeyLogin$txtMPassword"] = getpass.getpass("Password: ") | |
br.submit() | |
# Submit the post-login form (WTF is this?) | |
br.select_form(name="_xclick") | |
br.submit() | |
# Click the "continue" button on the next page (again, WTF?) | |
br.form = list(br.forms())[0] | |
br.submit() | |
# WE'RE IN! | |
# Get the registration worksheet | |
br.open("https://acadinfo.wustl.edu/apps/RegistrationWS/") | |
print br.response().read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment