Created
December 31, 2015 21:05
-
-
Save chandruscm/bdd31161664d7991210e to your computer and use it in GitHub Desktop.
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 | |
import time | |
url = 'https://aums-apps-6.amrita.edu:8443/portal/tool/3193c471-8aec-4c93-b000-66166b6c483b' | |
br = mechanize.Browser() | |
br.set_handle_robots(False) | |
br.set_handle_refresh(False) | |
def login(username,password): | |
br.open(url) | |
br.select_form(nr = 0) | |
br.form['username'] = username | |
br.form['password'] = password | |
start_time = time.time() | |
print '\nlogging in...' | |
br.submit() | |
print 'Connection established.' | |
print ('\n\n Faculty ' + '\t' + ' status \n').expandtabs(50) | |
for link in br.links(): | |
if link.text == 'Evaluations dashboard' : continue | |
submitForm(link.url) | |
print (link.text + '\t' + '[ completed ]').expandtabs(50) | |
print '\nElapsed time : '+ str(time.time() - start_time) + ' seconds' | |
def submitForm(form_url): | |
br.open(form_url) | |
br.select_form(nr = 0) | |
urlPart1 = 'form-branch::categorySection::itemrow:' | |
urlPart2 = ':renderedItem::nextrow:' | |
urlPart3 = ':verticalDisplay::dummyRadio-selection' | |
for i in range(16): | |
finalUrl = urlPart1+urlPart2+str(i+1)+urlPart3 if i == 0 else urlPart1+str(i)+urlPart2+str(i+1)+urlPart3 | |
br.form[finalUrl] = ['0'] | |
br.submit() | |
br.back() | |
def input(): | |
username = raw_input(' > Enter username :: ') | |
password = getpass.getpass(' > Enter password :: ') | |
login(username,password) | |
input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment