#!/bin/bash if [ -f /tmp/polls.txt ]; then cat /tmp/polls.txt exit 0 fi result=$(paste -d ' ' <(curl -sL -A 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36' "https://ewybory.eu/wybory-prezydenckie-2025-polska/sondaze-prezydenckie/" | pup 'div#all1.pollcom2 script' text{} | awk '/series: \[/, /^[[:space:]]*\]/{print}' | grep -o "'[A-Za-zĄĆĘŁŃÓŚŹŻąćęłńóśźż]\{1,\}'" | sed "s/'//g" | grep -v circle | grep -v Dash | uniq) <(curl -sL -A 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36' "https://ewybory.eu/wybory-prezydenckie-2025-polska/sondaze-prezydenckie/" | pup 'div#all1.pollcom2 script' text{} | awk '/series: \[/, /^[[:space:]]*\]/{print}' | grep -v "dash" | grep '[^0-9]' | grep "data" | sed 's/.*data://' | sed 's/\].*//' | sed 's/^[^0-9]*//' | sed "s/'.*//" | sed 's/,\s*$//' | awk -F', ' '{ n = NF; sum = 0; count = (n >= 3) ? 3 : n; for (i = n; i > n - count; i--) sum += $i; avg = (count > 0) ? int(sum / count) : 0; printf "%.0f\n", avg; }')) echo "$result" | awk ' { if ($1 == "BRAUN") initials = "BR"; else if ($1 == "BIEJAT") initials = "BIE"; else initials = substr($1, 1, 1); printf "%s%d, ", initials, $2; }' | sed 's/, $/\n/' | sed -e 's/BR/??‍♂️/g' -e 's/BIE/??‍♀️/g' -e 's/N/??‍♂️/g' -e 's/T/?/g' -e 's/J/?/g' -e 's/M/✡️/g' -e 's/Z/??/g' -e 's/H/?‍?/g' -e 's/,//g' > /tmp/polls.txt if [ ! -s /tmp/polls.txt ] || [ $(find /tmp/polls.txt -mmin +600) ]; then rm /tmp/polls.txt fi cat /tmp/polls.txt