Skip to content

Instantly share code, notes, and snippets.

@JDougherty
Last active December 31, 2015 16:29
Show Gist options
  • Save JDougherty/8014167 to your computer and use it in GitHub Desktop.
Save JDougherty/8014167 to your computer and use it in GitHub Desktop.
import mechanize
from BeautifulSoup import BeautifulSoup
USERNAME = "foo@bar.com"
PASSWORD = "quxadux"
def main():
browser = mechanize.Browser()
print "Opening login page..."
browser.open("https://www.applyweb.com/cgi-bin/ustat?gatechg")
browser.open("https://www.applyweb.com/shibboleth/gatekeeper?dest=https%3A%2F%2Fwww.applyweb.com%2Fcgi-bin%2Fustat%3Fgatechg")
browser.select_form(nr=0)
browser["j_username"] = USERNAME
browser["j_password"] = PASSWORD
print "Logging in..."
response = browser.submit()
browser.select_form(nr=0)
print "Redirecting..."
browser.submit()
response = browser.open("https://www.applyweb.com/cgi-bin/ustat?app_code=gatechg")
response = response.read()
soup = BeautifulSoup(response)
status = soup.findAll('span', attrs={"class":"ufe-ustat-checklist-label"}, text="Application Status")[0].parent.parent.findNextSibling().text
print "Application Status: %s" % status
for note in soup.findAll(text="Note from Graduate Admissions"):
print "Note from Graduate Admissions:\n%s" % note.parent.parent.findNextSibling().text
if __name__ == '__main__':
main()
@merckens
Copy link

Haha, we totally should have touched base. Nice though! I like it a lot.

@merckens
Copy link

(That login redirect stuff was nonsense.)

@JDougherty
Copy link
Author

Ha, tell me about it. It also wasn't made any easier by the fact that I had a typo in my username and could not figure out for quite some time why I couldn't get the login to work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment