Files
FarmaFinder/n8n/workflow-sdk-simple.js
Antoni Nuñez Romeu 05b99e9ed4 feat: working scraping for Promofarma, DocMorris, and Primor
- Fixed Primor URL format and selectors
- Created simple N8N webhook that calls scraper API
- All 3 sources now working:
  - Promofarma: 20 products
  - DocMorris: 10 products
  - Primor: 20 products
- Total: 130 products in database
- N8N webhook at /webhook/scrape working correctly
2026-07-16 15:19:07 +02:00

52 lines
1.1 KiB
JavaScript

import { workflow, node, trigger } from '@n8n/workflow-sdk';
const webhook = trigger({
type: 'n8n-nodes-base.webhook',
version: 2,
config: {
name: 'Webhook',
position: [240, 300],
parameters: {
httpMethod: 'POST',
path: 'scrape',
responseMode: 'lastNode'
}
},
output: [{}]
});
const callApi = node({
type: 'n8n-nodes-base.httpRequest',
version: 4.2,
config: {
name: 'Call Scraper API',
position: [440, 300],
parameters: {
method: 'POST',
url: 'http://parapharmacy-api:3002/api/scrape',
sendBody: true,
specifyBody: 'json',
jsonBody: '={{ JSON.stringify($json.body || { queries: ["capricare"], sources: ["promofarma"] }) }}'
}
},
output: [{}]
});
const response = node({
type: 'n8n-nodes-base.code',
version: 2,
config: {
name: 'Response',
position: [640, 300],
parameters: {
jsCode: `return [{ json: $input.first().json }];`
}
},
output: [{}]
});
export default workflow('scrape-simple', 'Parapharmacy Scraper Simple')
.add(webhook)
.to(callApi)
.to(response);