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

176
scraper/QUICKSTART.md Executable file
View File

@@ -0,0 +1,176 @@
# 🚀 GUIA RÁPIDO - 5 MINUTOS
## ⚡ **SETUP IMEDIATO**
### **1. Instalar (2 min)**
```bash
cd /media/ealmeida/Dados/Dev/Scripts/scraper/
source .venv/bin/activate # Ativar venv existente
python -m playwright install chromium # Se ainda não instalado
```
### **2. Configurar .env (1 min)**
```bash
cp .env.example .env
nano .env
```
Mínimo necessário:
```bash
# Se NÃO vais usar formatação AI, deixa vazio
OPENROUTER_API_KEY=
# Se NÃO vais scrape Reddit, deixa vazio
REDDIT_CLIENT_ID=
REDDIT_CLIENT_SECRET=
```
### **3. Executar (2 min)**
#### **Para os teus 30 sites:**
```bash
# TODOS os sites (exceto Reddit)
python batch_scraper.py --all
# Output: output_md/*.md
```
#### **Apenas Reddit:**
```bash
# Requer credenciais em .env
python batch_scraper.py --reddit-only
```
#### **Tudo junto:**
```bash
python batch_scraper.py --all --include-reddit
```
---
## 📊 **O QUE VAI ACONTECER**
```
[00:00] Iniciando batch...
[00:05] ✓ thehogring.com (15 páginas)
[00:12] ✓ sailrite.com (8 páginas)
[00:20] ✓ thesamba.com/vw/forum (23 páginas)
...
[02:30] Batch concluído: 28/30 sites (93% sucesso)
[02:30] Relatório: batch_report_20251105_143022.json
```
**Output**:
- `output_md/*.md` - Ficheiros Markdown
- `batch_report_*.json` - Relatório detalhado
- `batch_scraper_*.log` - Logs completos
---
## 🔧 **CUSTOMIZAÇÃO RÁPIDA**
### **Filtrar por tipo:**
```bash
# Apenas WordPress (rápido)
python batch_scraper.py --types wordpress
# Apenas fóruns (lento, muitas páginas)
python batch_scraper.py --types forum
# E-commerce (médio)
python batch_scraper.py --types ecommerce
```
### **Adicionar novo site:**
Edita `sites_config.json`:
```json
{
"sites": [
...
{
"name": "Novo Site",
"url": "https://novosite.com",
"type": "wordpress",
"max_depth": 2
}
]
}
```
---
## ⚠️ **PROBLEMAS COMUNS**
### **"ModuleNotFoundError: playwright"**
```bash
pip install -r requirements.txt
python -m playwright install chromium
```
### **"Timeout" constante**
```bash
# Sites lentos = aumentar timeout
# Editar sites_config.json e adicionar:
"request_timeout": 120
```
### **"403 Forbidden"**
```bash
# Anti-bot detetado
# Aumentar delays:
"politeness_delay": [5, 10]
```
---
## 📈 **PRÓXIMOS PASSOS**
### **Limpeza (opcional):**
```bash
python clean_md.py output_md/ output_cleaned/
```
### **Formatação AI (opcional, requer API):**
```bash
python format_content.py
```
---
## 💡 **DICAS PRO**
1. **Testar 1 site primeiro:**
```bash
# Editar sites_config.json
# Deixar apenas 1 site
python batch_scraper.py --all
```
2. **Executar em background:**
```bash
nohup python batch_scraper.py --all > execution.log 2>&1 &
# Monitora com: tail -f execution.log
```
3. **Scraping noturno:**
```bash
# Agendar para 02:00
echo "0 2 * * * cd /caminho/scraper && .venv/bin/python batch_scraper.py --all" | crontab -
```
---
## 📞 **AJUDA IMEDIATA**
- Ler `README.md` secção Troubleshooting
- Verificar logs: `tail -f batch_scraper_*.log`
- Testar manualmente: `python scraper.py` (editar URL na linha 489)
---
**Tempo estimado total**: 2-4h para 30 sites
**Taxa de sucesso esperada**: 80-90%
**Output aproximado**: 2-5GB de ficheiros Markdown
Boa sorte! 🚀