#!/bin/bash URL="https://citaprevia.alicante.es/citaprevia/pedir-cita" UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" MAX=25 for i in $(seq 1 $MAX); do echo "=== Attempt $i of $MAX ===" curl -sSL -A "$UA" "$URL" -o /tmp/cita_previa.html \ -w "HTTP:%{http_code} SIZE:%{size_download} TIME:%{time_total}\n" \ --max-time 45 --connect-timeout 15 CODE=$? if [ $CODE -eq 0 ]; then SIZE=$(wc -c < /tmp/cita_previa.html) if [ "$SIZE" -gt 5000 ]; then echo "SUCCESS: got $SIZE bytes" break else echo "Got $SIZE bytes (too small), retrying..." fi elif [ $CODE -eq 28 ]; then echo "timeout, retrying..." else echo "curl error $CODE, retrying..." fi sleep $((i > 5 ? 5 : 3)) done