packt-loader/run.sh
2023-07-07 11:23:44 +02:00

17 lines
752 B
Bash
Executable File

#!/bin/sh
#set -x
#echo 'Logging in'
formid=$(curl -b cookies -c cookies -s https://www.packtpub.com/ | grep 'form_build_id' | head -n 1 | grep -Eo 'value="[^"]*"' | sed -E 's@value="(.*)"@\1@')
curl -b cookies -c cookies -s -F 'email=ChristianLupus@web.de' -F 'form_id=packt_user_login_form' -F 'password=naitsirhc' -F 'op=Login' -F "form_build_id=$formid" https://www.packtpub.com/ > /dev/null
#echo 'Obtaining free book information'
title=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | awk '/<h2>/,/<\/h2>/' | tr -d '\n\r\t' | grep -Po '<h2>.*?</h2>' | head -n 1 | sed 's@<h2>\(.*\)</h2>@\1@')
echo "The packt book today is \"$title\". You can find it under https://www.packtpub.com/eu/free-learning."