diff --git a/cpdAlerts.sh b/cpdAlerts.sh index 3371b60..eb3ae1e 100755 --- a/cpdAlerts.sh +++ b/cpdAlerts.sh @@ -32,9 +32,16 @@ function testNotification() { } function aragon { - echo "nada aún realizado. Aquí código para buscar en aragon" comunidad="Aragon" pdfFile=".boletin$comunidad.pdf" + mainURL="https://www.boa.aragon.es/PABOA/automa.htm" + todayURL=$(wget -q $mainURL -O - | grep -i -o "document.location.href=.*" | grep -Po '(?<=document.location.href=")[^"]*(?=")') + pdfURL1="https://www.boa.aragon.es/cgi-bin/EBOA/" + pdfURL2=$(wget -q $todayURL -O - | grep -i -o "" -m 1 | grep -o -i "href=\".*type=pdf\"" | grep -Po '(?<=href=")[^"]*(?=")') + pdfURL="${pdfURL1}${pdfURL2}" + wget -q $pdfURL -O $pdfFile + if [ "$(pdftotext $pdfFile - | grep -i -E -n -3 "$keyWords" | tee .cpds | wc -l)" = 0 ]; then echo "0 resultados"; rm -rf .cpds .boletin*; exit; else sendMail $pdfURL $comunidad;fi + rm -rf .boletin* } function barcelona {