Files
citas-getter/book_cita.sh
cc-ultrav-1 3c960c1ce5 Add booking artifacts, API data, and catalog files
- booking_log.txt: midnight run results (cita booked at 15:15, 3347ms RTT)
- fire_at_midnight.py: original midnight launch script
- book_cita.sh / book_at_midnight.py: booking shell scripts
- fetch_final.py / fetch_cita.sh: API fetch utilities
- services_full.js, controllers_full.js, app_real2.js: frontend source
- services_real.js, url.js: API endpoint references
- tipos_doc.json: document type data from API
- benchmark_results.json: server load profiling results
2026-10-04 02:40:30 +02:00

122 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
#
# Book Portugal Tardes (cola I) cita for Humberto Normey Gomez
# Runs at Oct 4 00:00:00 — when Oct 19 enters the 15-day booking window
#
# Usage: bash /tmp/book_cita.sh
#
# Strategy: try 16:00 first (user's requested time), then sweep
# backwards through all 9 available slots to beat bot hoarding.
#
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
BASE="https://webservices.alicante.es/WsCitaPreviaPublic-RESTWebService-context-root/rest/1"
CT="Content-Type: application/vnd.oracle.adf.action+json"
# User data
SERVICIO="S"
COLA="I"
FECHA="19-10-2026"
DOC="X2491454W"
NOMBRE="Humberto"
APE1="Normey"
APE2="Gomez"
TIPO="2" # NIE
TEL="687915599"
EMAIL="hj@normey.net"
IMPUESTOS="N"
COMENTARIO="Solicitud de Alta en el Padrón"
# Slots to try, in priority order (16:00 first, then earlier)
HORAS=("16:00" "15:45" "15:30" "15:15" "15:00" "14:45" "14:30" "16:15" "16:30")
echo "============================================"
echo " CitaPrevia Alicante — Auto Booking Script"
echo " Cola I (Portugal Tardes, Padron)"
echo " $FECHA"
echo " $(date '+%Y-%m-%d %H:%M:%S')"
echo "============================================"
echo ""
for HORA in "${HORAS[@]}"; do
TS=$(python3 -c "from datetime import datetime; print(datetime.now().strftime('%H:%M:%S'))")
MOTIVO="${TS} ${COMENTARIO}"
echo "--- Attempting: $FECHA at $HORA ---"
RESPONSE=$(timeout 15 curl -sS --max-time 12 --connect-timeout 5 \
-A "$UA" \
-H "$CT" \
-H "Origin: https://citaprevia.alicante.es" \
-H "Referer: https://citaprevia.alicante.es/CitaPrevia/" \
-X POST "$BASE/ScCitaVo1" \
-d "{\"name\":\"insertarCitaPrevia\",\"parameters\":[\
{\"servicio\":\"$SERVICIO\"},\
{\"cola\":\"$COLA\"},\
{\"fecha\":\"$FECHA\"},\
{\"hora\":\"$HORA\"},\
{\"documento\":\"$DOC\"},\
{\"ip\":\"0.0.0.0\"},\
{\"nombre\":\"$NOMBRE\"},\
{\"apellido1\":\"$APE1\"},\
{\"apellido2\":\"$APE2\"},\
{\"tipo\":\"$TIPO\"},\
{\"telefono\":\"$TEL\"},\
{\"email\":\"$EMAIL\"},\
{\"impuestos\":\"$IMPUESTOS\"},\
{\"motivo\":\"$MOTIVO\"},\
{\"procedencia\":\"NULO\"}]}" 2>/dev/null)
RESULT=$(echo "$RESPONSE" | python3 -c "
import sys, json
try:
d = json.load(sys.stdin)
print(d.get('result', '(no result field)'))
except:
print('PARSE_ERROR')
" 2>/dev/null)
echo " Response: $RESULT"
if [ "$RESULT" = "Cita insertada" ]; then
echo ""
echo "*** SUCCESS! Cita booked for $FECHA at $HORA ***"
echo ""
echo "=== Booking Details ==="
echo " Servicio: $SERVICIO (SAC - SAIC)"
echo " Cola: $COLA (Portugal Tardes - Padron)"
echo " Fecha: $FECHA"
echo " Hora: $HORA"
echo " Nombre: $NOMBRE $APE1 $APE2"
echo " NIE: $DOC"
echo " Telefono: $TEL"
echo " Email: $EMAIL"
echo " Motivo: $MOTIVO"
echo ""
echo "=== To verify later, check with: ==="
echo " GET $BASE/ScServicioVo1/$SERVICIO/child/ScColaVo/$COLA "
echo " Or call getHorasCitas for $FECHA to confirm the slot is no longer listed."
echo ""
echo "=== To view/print your cita (from the frontend, once it's back up): ==="
echo " https://citaprevia.alicante.es/CitaPrevia/#/verCita/$DOC/$SERVICIO$COLA$DOC/OLD"
echo ""
exit 0
elif [ "$RESULT" = "Fecha posterior al limite permitido" ]; then
echo " → Still beyond the 15-day window. Wait for midnight."
exit 1
elif [ "$RESULT" = "Hora no permitida" ]; then
echo " → This slot is already taken."
elif echo "$RESULT" | grep -q "POSTULANTE"; then
echo " → Cita y Bono already exists for this person. Check existing cita."
exit 2
else
echo " → Other response. Stopping."
echo " Full response: $RESULT"
exit 3
fi
echo ""
done
echo "=== All 9 slots were taken. Try again tomorrow for next working day. ==="
exit 4