init: scripts diversos (crawlers, conversores, scrapers)

This commit is contained in:
2026-03-05 20:38:36 +00:00
commit 6ac6f4be2a
925 changed files with 850330 additions and 0 deletions

97
scraper/monitor_gemini.sh Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/bash
# Monitor CTF_Carstuff Gemini 2.5 Flash Structure Progress
# Author: Descomplicar® Crescimento Digital
# Link: https://descomplicar.pt
# Copyright: 2025 Descomplicar®
OUTPUT_DIR="/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/formatted"
LOG_FILE="structure_execution_gemini.log"
clear
echo "═══════════════════════════════════════════════════════════════"
echo " 🚀 CTF_CARSTUFF - MONITOR ESTRUTURAÇÃO GEMINI 2.5 FLASH"
echo " Modelo: google/gemini-2.5-flash | Custo: 40x mais barato que Claude"
echo "═══════════════════════════════════════════════════════════════"
echo ""
# Verificar se processo está a correr
if pgrep -f "structure_content_ctf.py" > /dev/null; then
echo "✅ Status: ATIVO (processamento Gemini 2.5 Flash)"
echo ""
else
echo "⚠️ Status: CONCLUÍDO ou PARADO"
echo ""
fi
# Contar ficheiros
MD_COUNT=$(find "$OUTPUT_DIR" -type f -name "structured_*.md" 2>/dev/null | wc -l)
JSON_COUNT=$(find "$OUTPUT_DIR" -type f -name "structured_*.json" 2>/dev/null | wc -l)
TOTAL_SIZE=$(du -sh "$OUTPUT_DIR" 2>/dev/null | cut -f1)
echo "📊 Progresso Atual:"
echo " • Ficheiros MD estruturados: $MD_COUNT / 822"
echo " • Ficheiros JSON gerados: $JSON_COUNT / 822"
echo " • Tamanho total: $TOTAL_SIZE"
echo ""
# Calcular percentagem
if [ $MD_COUNT -gt 0 ]; then
PERCENT=$((MD_COUNT * 100 / 822))
echo " 🎯 Progresso: $PERCENT%"
echo ""
fi
# Tempo estimado (~6s por ficheiro com Gemini)
if [ $MD_COUNT -gt 0 ]; then
REMAINING=$((822 - MD_COUNT))
SECONDS=$((REMAINING * 6)) # ~6s por ficheiro (Gemini)
MINUTES=$((SECONDS / 60))
HOURS=$((MINUTES / 60))
REMAINING_MIN=$((MINUTES % 60))
echo " ⏱️ Tempo estimado restante: ${HOURS}h ${REMAINING_MIN}m"
echo ""
fi
# Velocidade atual
echo "⚡ Performance:"
RECENT_COUNT=$(tail -100 "$LOG_FILE" 2>/dev/null | grep -c "✓ Guardado")
if [ $RECENT_COUNT -gt 0 ]; then
echo " • Últimos 100 logs: $RECENT_COUNT ficheiros processados"
AVG_TIME=$(tail -100 "$LOG_FILE" 2>/dev/null | grep "Processando" | tail -20 | wc -l)
if [ $AVG_TIME -gt 0 ]; then
echo " • Média ~5-7s por ficheiro (Gemini 2.5 Flash)"
fi
fi
echo ""
# Últimos ficheiros processados
echo "📝 Últimas atividades:"
tail -10 "$LOG_FILE" 2>/dev/null | grep -E "(Processando|✓ Guardado)" | sed 's/^/ /'
echo ""
# Estatísticas de sucesso/erro
SUCESSOS=$(grep -c "✓ Guardado" "$LOG_FILE" 2>/dev/null)
ERROS=$(grep -c "ERROR" "$LOG_FILE" 2>/dev/null)
echo "📈 Estatísticas:"
echo " • Sucessos: $SUCESSOS"
echo " • Erros: $ERROS"
if [ $SUCESSOS -gt 0 ]; then
TAXA=$((SUCESSOS * 100 / (SUCESSOS + ERROS + 1)))
echo " • Taxa de sucesso: ${TAXA}%"
fi
echo ""
# Estimativa custo
echo "💰 Estimativa Custo (vs Claude):"
echo " • Claude 3.5 Sonnet: ~\$120-180 para 822 ficheiros"
echo " • Gemini 2.5 Flash: ~\$3-5 para 822 ficheiros"
echo " • Poupança: ~97% 🎉"
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "Comandos úteis:"
echo " • Ver log: tail -f structure_execution_gemini.log"
echo " • Ver ficheiros: ls -lh $OUTPUT_DIR"
echo " • Parar: pkill -f structure_content_ctf.py"
echo "═══════════════════════════════════════════════════════════════"