init: scripts diversos (crawlers, conversores, scrapers)
This commit is contained in:
331
scraper/CTF_CARSTUFF_GUIDE.md
Executable file
331
scraper/CTF_CARSTUFF_GUIDE.md
Executable file
@@ -0,0 +1,331 @@
|
||||
# 🚗 GUIA CTF_CARSTUFF - Scraping Knowledge Base
|
||||
|
||||
**Cliente**: CTF_Carstuff
|
||||
**Objetivo**: Construir knowledge base sobre estofamento automotivo
|
||||
**Sites**: 18 sites + 2 subreddits Reddit
|
||||
**Output**: `/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/`
|
||||
|
||||
---
|
||||
|
||||
## ⚡ EXECUÇÃO RÁPIDA
|
||||
|
||||
### **Opção 1: TODOS os sites (Recomendado para primeira execução)**
|
||||
```bash
|
||||
cd /media/ealmeida/Dados/Dev/Scripts/scraper/
|
||||
source .venv/bin/activate
|
||||
python batch_scraper.py --config ctf_config.json --all
|
||||
```
|
||||
|
||||
**Tempo estimado**: 2-4 horas
|
||||
**Output**: 200-500 páginas em Markdown
|
||||
|
||||
---
|
||||
|
||||
## 🎯 EXECUÇÃO POR PRIORIDADE
|
||||
|
||||
### **Alta Prioridade (Sites principais - Executar primeiro)**
|
||||
Sites incluídos:
|
||||
- The Hog Ring (blog principal estofamento)
|
||||
- TheSamba Main + Forum (VW clássicos)
|
||||
- Portal dos Clássicos (fórum PT - mercado local)
|
||||
|
||||
```bash
|
||||
# Criar config temporário apenas com high priority
|
||||
python -c "
|
||||
import json
|
||||
with open('ctf_config.json') as f:
|
||||
config = json.load(f)
|
||||
high_priority = [s for s in config['sites'] if s.get('priority') == 'high']
|
||||
config['sites'] = high_priority
|
||||
with open('ctf_high_priority.json', 'w') as f:
|
||||
json.dump(config, f, indent=2)
|
||||
"
|
||||
|
||||
# Executar
|
||||
python batch_scraper.py --config ctf_high_priority.json --all
|
||||
```
|
||||
|
||||
### **Média Prioridade (Sites secundários)**
|
||||
Sites incluídos:
|
||||
- Sailrite, Albright Supply, Relicate
|
||||
- Pelican Parts Forum (Porsche)
|
||||
- MG Experience, Triumph, Alfa BB Forums
|
||||
- Camira Fabrics, Sunbrella
|
||||
|
||||
```bash
|
||||
# Filtrar apenas medium priority
|
||||
python batch_scraper.py --config ctf_config.json --types wordpress forum ecommerce
|
||||
```
|
||||
|
||||
### **Baixa Prioridade (Risco anti-bot - Executar por último)**
|
||||
Sites incluídos:
|
||||
- Cruisers Forum, Trawler Forum (marítimo)
|
||||
- Vans Air Force (aviação)
|
||||
- Keyston Bros, Ultrafabrics (possível anti-bot)
|
||||
|
||||
⚠️ **ATENÇÃO**: Estes sites podem falhar devido a proteções anti-bot.
|
||||
**Solução**: Executar em horário de baixo tráfego (02:00-06:00)
|
||||
|
||||
---
|
||||
|
||||
## 📊 ESTRUTURA DE OUTPUT
|
||||
|
||||
```
|
||||
/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/
|
||||
├── output_md/ # 📄 FASE 1: Markdown RAW (extração)
|
||||
│ ├── thehogring_com/
|
||||
│ ├── sailrite_com/
|
||||
│ ├── reddit_Autoupholstery/
|
||||
│ └── ...
|
||||
│
|
||||
├── output_cleaned/ # 🧹 FASE 2: Markdown LIMPO (após clean_md.py)
|
||||
│ └── [mesma estrutura]
|
||||
│
|
||||
├── formatted/ # ✨ FASE 3: Formatado AI (após format_content.py)
|
||||
│ └── [mesma estrutura]
|
||||
│
|
||||
└── logs/ # 📝 Logs e relatórios
|
||||
├── batch_scraper_20251105_025256.log
|
||||
└── batch_report_20251105_025256.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 PIPELINE COMPLETO (3 Fases)
|
||||
|
||||
### **FASE 1: Extração (Scraping)**
|
||||
```bash
|
||||
python batch_scraper.py --config ctf_config.json --all
|
||||
```
|
||||
**Output**: `output_md/` - Markdown bruto com todo conteúdo
|
||||
|
||||
### **FASE 2: Limpeza**
|
||||
```bash
|
||||
python clean_md.py \
|
||||
/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/output_md/ \
|
||||
/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/output_cleaned/
|
||||
```
|
||||
**Output**: `output_cleaned/` - Remove HTML residual, normaliza formatação
|
||||
|
||||
### **FASE 3: Formatação AI (Opcional)**
|
||||
⚠️ **Requer**: API key OpenRouter em `.env`
|
||||
|
||||
```bash
|
||||
# Editar format_content.py para apontar para diretório CTF
|
||||
# Linha ~50: INPUT_DIR = "/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/output_cleaned/"
|
||||
# Linha ~51: OUTPUT_DIR = "/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/formatted/"
|
||||
|
||||
python format_content.py
|
||||
```
|
||||
**Output**: `formatted/` - Conteúdo profissionalmente formatado
|
||||
|
||||
---
|
||||
|
||||
## 🤖 REDDIT (Opcional)
|
||||
|
||||
Para incluir Reddit (requer credenciais):
|
||||
|
||||
### **1. Criar credenciais Reddit**
|
||||
1. Ir a: https://reddit.com/prefs/apps
|
||||
2. Clicar "create app"
|
||||
3. Tipo: "script"
|
||||
4. Redirect URI: `http://localhost:8080`
|
||||
5. Copiar `CLIENT_ID` e `CLIENT_SECRET`
|
||||
|
||||
### **2. Adicionar ao `.env`**
|
||||
```bash
|
||||
REDDIT_CLIENT_ID=your-client-id
|
||||
REDDIT_CLIENT_SECRET=your-client-secret
|
||||
REDDIT_USER_AGENT=CTF_Scraper/1.0 by YourUsername
|
||||
```
|
||||
|
||||
### **3. Executar com Reddit**
|
||||
```bash
|
||||
# Apenas Reddit
|
||||
python batch_scraper.py --config ctf_config.json --reddit-only
|
||||
|
||||
# Sites + Reddit
|
||||
python batch_scraper.py --config ctf_config.json --all --include-reddit
|
||||
```
|
||||
|
||||
**Subreddits configurados**:
|
||||
- r/Autoupholstery
|
||||
- r/upholstery
|
||||
|
||||
**Limite**: 50 posts/subreddit, ordenados por top (último ano)
|
||||
|
||||
---
|
||||
|
||||
## 📋 SITES CONFIGURADOS
|
||||
|
||||
### **🇵🇹 Sites Português (Prioridade Alta)**
|
||||
- **Portal dos Clássicos** - `https://forum.portaldosclassicos.com`
|
||||
Fórum PT sobre automóveis clássicos (mercado local)
|
||||
|
||||
### **🌐 Sites Principais (Prioridade Alta)**
|
||||
- **The Hog Ring** - `https://www.thehogring.com/`
|
||||
Blog principal sobre estofamento automotivo
|
||||
- **TheSamba Main** - `https://thesamba.com`
|
||||
Recurso sobre VW clássicos
|
||||
- **TheSamba VW Forum** - `https://thesamba.com/vw/forum/`
|
||||
Fórum VW - comunidade ativa
|
||||
|
||||
### **🛒 E-commerce (Prioridade Média)**
|
||||
- Sailrite, Albright Supply, Relicate
|
||||
- Camira Fabrics, Sunbrella (fornecedores tecidos)
|
||||
|
||||
### **💬 Fóruns Marca (Prioridade Média)**
|
||||
- Pelican Parts (Porsche)
|
||||
- MG Experience, Triumph, Alfa BB
|
||||
|
||||
### **⚓ Marítimo/Aviação (Prioridade Baixa)**
|
||||
- Cruisers Forum, Trawler Forum (barcos)
|
||||
- Vans Air Force (aviação)
|
||||
|
||||
### **⚠️ Anti-bot Risk (Prioridade Baixa)**
|
||||
- Keyston Bros, Ultrafabrics (e-commerce com proteção)
|
||||
|
||||
---
|
||||
|
||||
## ⏱️ ESTIMATIVAS DE TEMPO
|
||||
|
||||
| Categoria | Sites | Páginas Estimadas | Tempo |
|
||||
|-----------|-------|-------------------|-------|
|
||||
| **Alta prioridade** | 4 sites | 100-200 páginas | 45-90min |
|
||||
| **Média prioridade** | 9 sites | 150-250 páginas | 1.5-2.5h |
|
||||
| **Baixa prioridade** | 5 sites | 50-100 páginas | 1-2h |
|
||||
| **Reddit** | 2 subreddits | 100 posts | 2-5min |
|
||||
| **TOTAL** | 18 + Reddit | 400-650 itens | 3-5h |
|
||||
|
||||
---
|
||||
|
||||
## 🔍 MONITORIZAÇÃO
|
||||
|
||||
### **Ver progresso em tempo real**:
|
||||
```bash
|
||||
tail -f /media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/logs/batch_scraper_*.log
|
||||
```
|
||||
|
||||
### **Ver relatório final**:
|
||||
```bash
|
||||
cat /media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/logs/batch_report_*.json
|
||||
```
|
||||
|
||||
Relatório inclui:
|
||||
- Total sites processados
|
||||
- Sites com sucesso vs falhados
|
||||
- Número de páginas por site
|
||||
- Erros detalhados
|
||||
- Tempo total de execução
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ SITES COM POSSÍVEIS PROBLEMAS
|
||||
|
||||
### **Anti-bot Forte**:
|
||||
- ❌ **keystonbros.com** - E-commerce com proteção Cloudflare
|
||||
- ❌ **ultrafabricsinc.com** - E-commerce com verificação JS
|
||||
|
||||
**Solução**: Executar em horário baixo tráfego (madrugada)
|
||||
|
||||
### **Muito Lento/Grande**:
|
||||
- ⚠️ **cruisersforum.com** - Milhares de threads
|
||||
- ⚠️ **trawlerforum.com** - Milhares de threads
|
||||
|
||||
**Solução**: Já configurado `max_depth=1` para limitar
|
||||
|
||||
### **Requer Validação URL**:
|
||||
- ⚠️ Sites alemães (Autosattler.de, Lederzentrum)
|
||||
- ⚠️ Sites espanhóis (Piel de Toro)
|
||||
|
||||
**Status**: Incluídos na config mas podem necessitar ajustes
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ TROUBLESHOOTING
|
||||
|
||||
### **Erro: "Timeout"**
|
||||
```bash
|
||||
# Editar ctf_config.json, aumentar timeout:
|
||||
"scraper_settings": {
|
||||
"request_timeout": 120 # Aumentar de 60 para 120
|
||||
}
|
||||
```
|
||||
|
||||
### **Erro: "403 Forbidden"**
|
||||
```bash
|
||||
# Aumentar delays em ctf_config.json:
|
||||
"scraper_settings": {
|
||||
"politeness_delay": [5, 10] # Aumentar de [2,5] para [5,10]
|
||||
}
|
||||
```
|
||||
|
||||
### **Site específico falhando**
|
||||
```bash
|
||||
# Remover temporariamente do ctf_config.json
|
||||
# Executar restantes sites
|
||||
# Tentar site problemático individualmente depois
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 RECOMENDAÇÕES
|
||||
|
||||
### **Primeira Execução**:
|
||||
1. ✅ Executar **apenas alta prioridade** primeiro
|
||||
2. ✅ Validar output em `output_md/`
|
||||
3. ✅ Se OK, executar **média prioridade**
|
||||
4. ✅ Por último, **baixa prioridade** (madrugada)
|
||||
|
||||
### **Execução Programada**:
|
||||
```bash
|
||||
# Executar automaticamente todas as noites às 02:00
|
||||
echo "0 2 * * * cd /media/ealmeida/Dados/Dev/Scripts/scraper && .venv/bin/python batch_scraper.py --config ctf_config.json --all" | crontab -
|
||||
```
|
||||
|
||||
### **Backup**:
|
||||
```bash
|
||||
# Backup periódico do knowledge base
|
||||
tar -czf kb_backup_$(date +%Y%m%d).tar.gz \
|
||||
/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/output_md/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📞 SUPORTE
|
||||
|
||||
- **Documentação geral**: `README.md`
|
||||
- **Guia rápido**: `QUICKSTART.md`
|
||||
- **Validação setup**: `python validate_setup.py`
|
||||
- **Implementações**: `IMPLEMENTADO.md`
|
||||
|
||||
---
|
||||
|
||||
## 📈 PRÓXIMOS PASSOS
|
||||
|
||||
1. **Executar primeira extração**:
|
||||
```bash
|
||||
python batch_scraper.py --config ctf_config.json --all
|
||||
```
|
||||
|
||||
2. **Validar resultados**:
|
||||
```bash
|
||||
ls -lh /media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/output_md/
|
||||
```
|
||||
|
||||
3. **Limpar conteúdo** (Fase 2):
|
||||
```bash
|
||||
python clean_md.py [input] [output]
|
||||
```
|
||||
|
||||
4. **Opcional: Formatar com AI** (Fase 3):
|
||||
```bash
|
||||
python format_content.py # Após configurar paths
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ PRONTO PARA USO
|
||||
**Última atualização**: 2025-11-05
|
||||
**Author**: Descomplicar® Crescimento Digital
|
||||
**Link**: https://descomplicar.pt
|
||||
Reference in New Issue
Block a user