2022-04-25 14:30:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-12 20:25:58 +00:00
|
|
|
urls=$(for item in $(wget https://covid19.min-saude.pt/numero-de-novos-casos-e-obitos-por-dia/ -o /dev/null -O - | hxnormalize -x -l 1000| hxselect .wp-block-spms-accordion-item|hxselect a -s'\n'); do echo "$item"|grep href; done|cut -d\" -f2|grep -v http://Novos);
|
2022-04-25 14:30:12 +00:00
|
|
|
|
2023-04-12 20:25:58 +00:00
|
|
|
nurls=$(echo "$urls"|grep -v ^$|wc -l);
|
|
|
|
nnxls=$(echo "$urls"|grep -v ^$|grep -c -v xlsx);
|
2022-04-25 14:30:12 +00:00
|
|
|
|
|
|
|
if [ "$nurls" -eq "0" ]; then
|
|
|
|
echo "covid: não foram encontrados urls, script não deve estar a funcionar correctamente.";
|
2023-07-04 17:37:25 +00:00
|
|
|
echo "DEBUG:"
|
|
|
|
wget https://covid19.min-saude.pt/numero-de-novos-casos-e-obitos-por-dia/ && cat index.html && rm index.html
|
2022-10-05 14:12:25 +00:00
|
|
|
elif [ "$nnxls" -ne "0" ]; then
|
2023-02-18 18:39:23 +00:00
|
|
|
echo "covid: há ($nnxls/$nurls) endereços que não são xlsx, incumprimento pode já não existir";
|
2023-07-06 18:08:47 +00:00
|
|
|
echo "NOTA: tentaste isto vindo dos IPs do github? Se sim, provavelmente bateste num 405 Method Not Allowed...";
|
2022-04-25 14:30:12 +00:00
|
|
|
else
|
|
|
|
echo "covid: Incumprimento mantém-se, a actualizar o README (faça um git diff, valide, e commit!)";
|
|
|
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
2023-02-18 18:39:23 +00:00
|
|
|
test "$(echo "$line"|grep -v -c "covid19")" -eq "1" \
|
2022-04-25 14:30:12 +00:00
|
|
|
&& echo "$line" \
|
2024-10-18 19:31:33 +00:00
|
|
|
|| (h=$(echo "$line"|cut -d\| -f1-4); t=$(echo "$line"|cut -d\| -f6-); nc=$(echo "$line"|cut -d\| -f5 | wc -m); printf "%s| %-$((nc-2))s|%s\n" "$h" "$(date +%Y/%m/%d)" "$t");
|
2022-04-25 14:30:12 +00:00
|
|
|
done < README.md > new
|
|
|
|
mv new README.md
|
|
|
|
fi
|