Skip to content

Instantly share code, notes, and snippets.

@gamma
Created April 26, 2018 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamma/f05255531918cf7b2b210d68dfdbfd25 to your computer and use it in GitHub Desktop.
Save gamma/f05255531918cf7b2b210d68dfdbfd25 to your computer and use it in GitHub Desktop.
Abzug der aktuellen Tageszeitung der MAZ Oberhavel
#!/bin/bash
USER="$1"
PASS="$2"
BASE="https://epaper.maz-online.de"
LOGIN=$(curl -v $BASE 2>&1)
COOKIE=$(echo "$LOGIN" | grep "Set-Cookie" | tail -n 1 | awk '{print $3}')
TOKEN=$(echo "$LOGIN" | grep "token" | awk -F\" '{print $6}')
AUTH=$(curl -vL --cookie "$COOKIE" -X POST -d "username=$USER" -d "password=$PASS" -d "token=$TOKEN" $BASE 2>&1)
LTOKEN=$(echo "$AUTH" | grep "ltoken" | awk -F\" '{print $20}')
####################
DATE=$(date +%Y%m%d)
ISSUEURL="$BASE/issuefiles/${DATE}_MAZOZ/pdfs/MAZOZ${DATE}_Gesamt.pdf"
MADSACK=$(curl -vL --cookie "$COOKIE" $ISSUEURL 2>&1)
MADCOOKIE=$(echo "$MADSACK" | grep "Set-Cookie" | tail -n 1 | awk '{print $3}')
MADPDF=$(curl -vL --cookie "$MADCOOKIE" "https://pdfcollector.madsack.de/maz/index.php/token/render_pdf/" 2>&1)
OUTPUT_FILE="MAZ-${DATE}.pdf"
MADPDF_DOWNLOAD=$(curl -vL --cookie "$MADCOOKIE" --output "$OUTPUT_FILE" "https://pdfcollector.madsack.de/maz/index.php/token/download_pdf/" 2>&1)
####################
LOGOUT=$(curl -vL --cookie "$COOKIE" -X POST -d "ltoken=$LTOKEN" "$BASE/logout" 2>&1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment