Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Last active September 11, 2016 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vgmoose/8533207 to your computer and use it in GitHub Desktop.
Save vgmoose/8533207 to your computer and use it in GitHub Desktop.
spire thing
USER='USERNAME' # edit this
PASS='PASSWORD' # edit this
rm cookies.txt
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
curl --silent -X GET 'https://spire.umass.edu' --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES --location >/dev/null
curl --silent -X POST 'https://www.spire.umass.edu/psp/heproda/' --user-agent $USER_AGENT --data-urlencode "userid=${USER}" --data-urlencode "pwd=${PASS}" --data-urlencode "languageCd=ENG" --data-urlencode "timezoneOffset=0" --data-urlencode "Submit=Go" --data-urlencode "cmd=login" --cookie $COOKIES --cookie-jar $COOKIES >/dev/null
curl --silent -X GET 'https://www.spire.umass.edu/psp/heproda/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL?FolderPath=PORTAL_ROOT_OBJECT.HCCC_ACADEMIC_RECORDS.HC_SSS_STUDENT_CENTER&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder' --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES > /dev/null
import subprocess, sys
# sychonrously run shell command
def understand(input):
try:
a = subprocess.check_output(input+" 2> .error", shell=True)
except Exception as e:
return str(subprocess.check_output("cat .error", shell=True)[:-1])
return a
def say(s):
print(s)
a = understand("./check_cart.sh")
while (a.find("Moved Temporarily") >0 or a.find("thoriz") > 0):
understand("./auth.sh");
a = understand("./check_cart.sh")
if (understand("echo \""+a+"\" | wc -l").lstrip(" ").rstrip("\n") == "3"):
say("Quickly, the class is open! http://spire.umass.edu");
elif (a == ""):
say("The discussion is closed, you need to change it! http://spire.umass.edu");
elif (understand("echo \""+a+"\" | wc -l").lstrip(" ").rstrip("\n") != "2"):
say(understand("echo \""+a+"\" | wc -l").lstrip(" ")
IFRAME='https://www.spire.umass.edu/psc/heproda/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES_2.SSR_SSENRL_CART.GBL?FolderPath=PORTAL_ROOT_OBJECT.HCCC_ENROLLMENT.HC_SSR_SSENRL_CART_GBL2&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder'
# Enter the following in the address bar:
# javascript:alert(document.getElementById("ptifrmtgtframe").src);
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
curl --silent -X GET $IFRAME --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES > result.html
cat result.html | grep "\"Open\"\|Moved\|thoriz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment