feat: complete N8N scrapers for 6 sources and seed script

- Create comprehensive N8N workflow for all 6 parapharmacy sources
- Create webhook-triggered manual scraping workflow
- Add seed script with 20 sample products
- Update n8n/README.md with complete documentation
- Update docs/parapharmacy.md with seeding instructions
- Add seed script to package.json

Sources configured:
- Promofarma
- Pharmarket
- DocMorris
- 1001Farma
- Primor
- MiFarma
This commit is contained in:
Antoni Nuñez Romeu
2026-07-16 13:00:20 +02:00
parent cb564fb170
commit 30f97fe87d
7 changed files with 973 additions and 68 deletions
+54 -14
View File
@@ -142,33 +142,43 @@ MONGODB_URI=mongodb://mongodb:27017/parapharmacy
## Workflows de Scraping
### 1. Parapharmacy Scraper (Automático)
| Workflow | Trigger | Estado | Descripción |
|----------|---------|--------|-------------|
| Parapharmacy Scraper - All Sources | Cada 3 días a las 2am | Inactivo | Scraping automático de las 6 tiendas |
| Parapharmacy Manual Scraper | POST `/webhook/scrape-all` | Activo | Scraping manual bajo demanda |
### 1. Parapharmacy Scraper - All Sources (Automático)
- **Trigger**: Cada 3 días a las 2:00 AM
- **Estado**: Inactivo por defecto
- **Función**: Scraping automático de Promofarma
- **Función**: Scraping automático de las 6 tiendas
**Para activar:**
1. Ir a http://localhost:5678/workflows
2. Abrir "Parapharmacy Scraper"
2. Abrir "Parapharmacy Scraper - All Sources"
3. Hacer clic en "Active" toggle
### 2. Parapharmacy Manual Scraper (Webhook)
- **Trigger**: POST a `/webhook/scrape-parapharmacy`
- **Trigger**: POST a `/webhook/scrape-all`
- **Estado**: Activo por defecto
- **Función**: Scraping bajo demanda
- **Función**: Scraping bajo demanda de todas las fuentes
**Uso:**
```bash
# Scraping con queries por defecto
curl -X POST http://localhost:5678/webhook/scrape-parapharmacy
# Scraping con queries por defecto (todas las tiendas)
curl -X POST http://localhost:5678/webhook/scrape-all
# Scraping con queries específicas
curl -X POST http://localhost:5678/webhook/scrape-parapharmacy \
curl -X POST http://localhost:5678/webhook/scrape-all \
-H "Content-Type: application/json" \
-d '{"queries": ["crema hidratante", "protector solar"]}'
# Scraping solo de fuentes específicas
curl -X POST http://localhost:5678/webhook/scrape-all \
-H "Content-Type: application/json" \
-d '{"sources": ["promofarma", "pharmarket"]}'
```
---
@@ -177,12 +187,42 @@ curl -X POST http://localhost:5678/webhook/scrape-parapharmacy \
| Fuente | URL | Estado |
|--------|-----|--------|
| Promofarma | promofarma.com | ✅ Implementado |
| Pharmarket | pharmarket.es | 🔄 Pendiente |
| DocMorris | docmorris.es | 🔄 Pendiente |
| 1001Farma | 1001farma.net | 🔄 Pendiente |
| Primor | primor.eu | 🔄 Pendiente |
| MiFarma | mifarma.es | 🔄 Pendiente |
| Promofarma | promofarma.com | ✅ Configurado |
| Pharmarket | pharmarket.es | ✅ Configurado |
| DocMorris | docmorris.es | ✅ Configurado |
| 1001Farma | 1001farma.net | ✅ Configurado |
| Primor | primor.eu | ✅ Configurado |
| MiFarma | mifarma.es | ✅ Configurado |
---
## Poblar Base de Datos
### Datos de Prueba
```bash
# Ejecutar seed script (inserta 20 productos de prueba)
cd apps/parapharmacy-api
npm run seed
```
### Scraping Real
```bash
# Ejecutar scraping manual via N8N webhook
curl -X POST http://localhost:5678/webhook/scrape-all
```
### Verificar Datos
```bash
# Buscar productos
curl "http://localhost:3002/api/products/search?q=crema"
# Contar productos
curl "http://localhost:3002/api/products?limit=1"
# Respuesta: { "total": 20, ... }
```
---