new: fetch grades from primuss

master
Toerd@archlinux 5 years ago
parent bba3424e2a
commit 3203dc6198

@ -0,0 +1 @@
temp1.forEach( e => { if (e.keyword === document.getElementsByClassName("term-keyword__keyword")[1].innerText.slice(1,-1) ) console.log(e.searchVolume)})

@ -0,0 +1,34 @@
#!/bin/bash
# author: phga
# date: 2020-07-28
# desc: Script to fetch grades from primuss...Not more, not less
DEST="https://www3.primuss.de/cgi-bin/login/index.pl?FH=fhin"
NOTEN="https://www3.primuss.de/cgi-bin/pg_Notenbekanntgabe/index.pl"
SHIBBLE="https://www3.primuss.de/Shibboleth.sso/SAML2/POST"
FU="https://www3.primuss.de/cgi-bin/pg_Notenbekanntgabe/showajax.pl"
USERNAME=phg0107
PASSWORD=lelelele
COOKIES=.cookies
HEADERS=.headers
rm $COOKIES
rm $HEADERS
curl -s -L -c $COOKIES -D $HEADERS "$DEST" > /dev/null
LOGIN=$(cat $HEADERS | rg -o -e "Location: (.*)" -r '$1' | tail -1 | sed 's/\;.*?/?/')
# Remove trailing \r
LOGIN=${LOGIN%$'\r'}
# This was quite helpful to look at the POST data and headers sent by client
# --trace-ascii stdout
# The param format and -d option were super crucial for this shit to work
VALS=($(curl -s -b $COOKIES -c $COOKIES -d "j_username=$USERNAME&j_password=$PASSWORD&_eventId_proceed=" $LOGIN | rg -o -e 'value="(.*)"' -r '$1'))
RELAYSTATE=$(echo ${VALS[0]} | sed 's/:/%3A/g')
# OIDDDAAAA die Plus-Zeichen eyyyy >:(
SAMLRESP=$(echo ${VALS[1]} | sed 's/=/%3D/g' | sed 's/+/%2B/g')
SESSION=$(curl -L -s -b $COOKIES -c $COOKIES -d "RelayState=$RELAYSTATE&SAMLResponse=$SAMLRESP" $SHIBBLE | rg -o -e 'name="Session" value="(.*)"' -r '$1' | head -1)
AJAXDATA=$(curl -s -b $COOKIES -c $COOKIES -d "User=$USERNAME&Session=$SESSION&Language=de&FH=fhin&Portal=1" $NOTEN | rg -o -e 'data: *"(.*)"' -r '$1' | head -1)
# Finally...
curl -s -b $COOKIES -c $COOKIES -d $AJAXDATA $FU | awk 'f{ if (/<\/tbody>/){printf "%s", buf; f=0; buf=""} else buf = buf $0 ORS}; /<tbody>/{f=1}' | rg -o -e '<b>(.*)</b>' -r '$1'
# Pipe output to file and if require perform futher formatting
Loading…
Cancel
Save