#!/bin/bash set -xe izhod=$1 emso=$2 geslo=$3 # mora biti urlencoded o=`umask` umask 0077 p=`rev <<<$0 | cut -d/ -f1 | rev` c=`mktemp -p "" $p.XXX.cookiejar` d=`mktemp -d -p "" $p.XXX` trap "rm $c; rm -r $d" EXIT r=`curl --cookie-jar $c --cookie $c https://matura.ric.si/ | grep __RequestVerificationToken | cut -d\" -f6` curl https://matura.ric.si/ -X POST --cookie $c --cookie-jar $c --data-raw "EMSO=$emso&Geslo=$geslo&__RequestVerificationToken=$r" -i | grep Kandidat > /dev/null || ( echo prijava z EMŠO $emso ni uspela; exit 1 ) sed -i $c -e "s/^#HttpOnly_//" pushd $d wget --convert-links --no-host-directories --mirror --load-cookies $c https://matura.ric.si/Kandidat?.html find -type f | grep Kandidat | xargs -I '{}' sed -i {} -e s/Rezultat?PredmetID/Rezultat%3FPredmetID/g # find -type f | grep Kandidat | xargs -I '{}' sed -i {} -e s,/DATOTEKE,../DATOTEKE,g # find -type f | grep Kandidat | xargs -I '{}' sed -i {} -e s,/datoteke,datoteke,g echo "" > $d/index.html rm $c umask $o zip -r $izhod . popd rm -fr $d