Skip to content

Instantly share code, notes, and snippets.

@tdeck
Last active August 3, 2016 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdeck/2cdb88af83bbd2cb67a7cda81b22694d to your computer and use it in GitHub Desktop.
Save tdeck/2cdb88af83bbd2cb67a7cda81b22694d to your computer and use it in GitHub Desktop.
Script to demonstrate logging into WebSTAC using Python Mechanize
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