125 lines
3.9 KiB
JSON
125 lines
3.9 KiB
JSON
|
|
{
|
||
|
|
"name": "Scrape Compras Paraguai",
|
||
|
|
"nodes": [
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"path": "search",
|
||
|
|
"responseMode": "lastNode",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"type": "n8n-nodes-base.webhook",
|
||
|
|
"typeVersion": 1,
|
||
|
|
"position": [
|
||
|
|
0,
|
||
|
|
0
|
||
|
|
],
|
||
|
|
"id": "webhook-trigger",
|
||
|
|
"name": "Webhook"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"url": "=https://www.comprasparaguai.com.br/busca/?q={{ $json.query.query.replace(/ /g, '+') }}",
|
||
|
|
"options": {}
|
||
|
|
},
|
||
|
|
"type": "n8n-nodes-base.httpRequest",
|
||
|
|
"typeVersion": 4.1,
|
||
|
|
"position": [
|
||
|
|
220,
|
||
|
|
0
|
||
|
|
],
|
||
|
|
"id": "http-request",
|
||
|
|
"name": "Fetch HTML"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"mode": "html",
|
||
|
|
"dataPropertyName": "data",
|
||
|
|
"selectors": [
|
||
|
|
{
|
||
|
|
"name": "products",
|
||
|
|
"selector": ".product-item",
|
||
|
|
"returnArray": true,
|
||
|
|
"properties": [
|
||
|
|
{
|
||
|
|
"name": "name",
|
||
|
|
"selector": ".product-title",
|
||
|
|
"value": "text"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "priceUSD",
|
||
|
|
"selector": ".price-dolar",
|
||
|
|
"value": "text"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "store",
|
||
|
|
"selector": ".store-name",
|
||
|
|
"value": "text"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"name": "link",
|
||
|
|
"selector": "a",
|
||
|
|
"attribute": "href"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"type": "n8n-nodes-base.htmlExtract",
|
||
|
|
"typeVersion": 1,
|
||
|
|
"position": [
|
||
|
|
440,
|
||
|
|
0
|
||
|
|
],
|
||
|
|
"id": "html-extract",
|
||
|
|
"name": "Extract Data"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"parameters": {
|
||
|
|
"jsCode": "const products = $input.all()[0].json.products || [];\n\nconst cleanProducts = products.map(p => ({\n name: p.name.trim(),\n priceUSD: parseFloat(p.priceUSD.replace('US$ ', '').replace(',', '.').trim()),\n priceBRL: parseFloat(p.priceUSD.replace('US$ ', '').replace(',', '.').trim()) * 5.75,\n store: p.store.trim(),\n url: 'https://www.comprasparaguai.com.br' + p.link\n})).filter(p => !isNaN(p.priceUSD));\n\nreturn cleanProducts;"
|
||
|
|
},
|
||
|
|
"type": "n8n-nodes-base.code",
|
||
|
|
"typeVersion": 2,
|
||
|
|
"position": [
|
||
|
|
660,
|
||
|
|
0
|
||
|
|
],
|
||
|
|
"id": "cleanup-code",
|
||
|
|
"name": "Clean Data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"connections": {
|
||
|
|
"Webhook": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Fetch HTML",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Fetch HTML": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Extract Data",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"Extract Data": {
|
||
|
|
"main": [
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"node": "Clean Data",
|
||
|
|
"type": "main",
|
||
|
|
"index": 0
|
||
|
|
}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|