From 4e51d06a1a3f7460e1e7034739299b7e6209d0a5 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 8 Jun 2017 14:37:02 +0200 Subject: [PATCH] Changed due to reCaptcha implementation on website to manual downloading --- run.sh | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/run.sh b/run.sh index c9f7961..662e22f 100755 --- a/run.sh +++ b/run.sh @@ -1,43 +1,16 @@ #!/bin/sh -echo 'Logging in' -curl -b cookies -c cookies -s -F 'email=ChristianLupus@web.de' -F 'form_id=packt_user_login_form' -F 'password=naitsirhc' -F 'op=Login' https://www.packtpub.com/ > /dev/null +#set -x -echo 'Obtaining free book information' -url=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | grep freelearning-claim | grep -o 'href="[^"]*' | grep -o '/free.*') +#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@') -echo 'Claiming free book' -curl -b cookies -c cookies https://www.packtpub.com$url +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 -opwd=$(pwd) -if [ $# -eq 1 ]; then - mkdir -p "$1" - cd "$1" -else - mkdir -p downloads - cd downloads -fi +#echo 'Obtaining free book information' +title=$(curl -b cookies -c cookies -s https://www.packtpub.com/packt/offers/free-learning | awk '/

/,/<\/h2>/' | tr -d '\n\r\t' | grep -Po '

.*?

' | head -n 1 | sed 's@

\(.*\)

@\1@') -echo 'Downloading books' -id=$(echo $url | grep -o '/[0-9/]*/' | grep -o '[0-9]*') -name=$(curl -b "$opwd/cookies" -c "$opwd/cookies" -sI https://www.packtpub.com/ebook_download/$id/pdf | grep 'Location' | grep -Eo 'https?://[^?]*' | sed 's@.*/@@' | sed 's@\.pdf@@i' ) -echo $name -out=$(curl -b "$opwd/cookies" -c "$opwd/cookies" -L https://www.packtpub.com/ebook_download/$id/pdf https://www.packtpub.com/ebook_download/$id/epub -o "$name.pdf" -o "$name.epub" 2>&1 ) -ret=$? +echo "The packt book today is \"$title\". You can find it under https://www.packtpub.com/packt/offers/free-learning." -cd "$opwd" - -echo 'Logging off' -curl -b cookies -c cookies -s https://www.packtpub.com/logout > /dev/null - -if [ $ret -ne 0 ]; then - - if [ $ret -eq 23 ]; then - echo Could not write file to file system: - fi - - echo -e "$out" - -fi