webservices/.node-red/flows.json
Mauro Rosero P. bc03b5bead
[IMPROVED] Flujo de Industrias Leads y documentación completa
- Añadido nuevo flujo "Industrias Leads" para procesar datos de empresas manufactureras
- Renombrado flujo de cooperativas para mayor consistencia
- Mejorada la organización visual de los nodos
- Respaldados archivos de configuración críticos
- Actualizada documentación del README.md con detalles de ambos flujos
- Actualizado CHANGELOG.md a versión 0.4.0

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-26 17:21:04 -05:00

458 lines
No EOL
13 KiB
JSON

[
{
"id": "7f0acab470911e6e",
"type": "tab",
"label": "Local Leads 507",
"disabled": false,
"info": "",
"env": []
},
{
"id": "772316e0710af934",
"type": "inject",
"z": "7f0acab470911e6e",
"name": "Start",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 100,
"wires": [
[
"14d7e672986e5a93"
]
]
},
{
"id": "14d7e672986e5a93",
"type": "http request",
"z": "7f0acab470911e6e",
"name": "Read IPACOOP",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://ipacoop.gob.pa/listado-de-cooperativas-obligadas/",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 160,
"y": 180,
"wires": [
[
"8c2bc9a9303297a6"
]
]
},
{
"id": "8c2bc9a9303297a6",
"type": "html",
"z": "7f0acab470911e6e",
"name": "Get html Table",
"property": "payload",
"outproperty": "payload",
"tag": "table",
"ret": "html",
"as": "multi",
"chr": "_",
"x": 420,
"y": 40,
"wires": [
[
"030626a963966e90"
]
]
},
{
"id": "072f59e44c2a666e",
"type": "html-pro",
"z": "7f0acab470911e6e",
"name": "Get data coops",
"property": "payload",
"outproperty": "payload",
"dotrim": true,
"selectors": [
{
"path": "td",
"key": "cols",
"returnValue": "0",
"attribute": "",
"returnArray": true
}
],
"x": 560,
"y": 260,
"wires": [
[
"b6385dfa3d13631a"
]
]
},
{
"id": "ef9384e43a31a072",
"type": "debug",
"z": "7f0acab470911e6e",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 120,
"wires": []
},
{
"id": "030626a963966e90",
"type": "html",
"z": "7f0acab470911e6e",
"name": "Get html rows",
"property": "payload",
"outproperty": "payload",
"tag": "tr",
"ret": "html",
"as": "multi",
"chr": "_",
"x": 420,
"y": 180,
"wires": [
[
"072f59e44c2a666e"
]
]
},
{
"id": "b6385dfa3d13631a",
"type": "function",
"z": "7f0acab470911e6e",
"name": "Set columns",
"func": "msg.payload = [ \n msg.payload.cols[0],\n msg.payload.cols[1], \n msg.payload.cols[2], \n msg.payload.cols[3], \n ]\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 670,
"y": 40,
"wires": [
[
"b4c01ef9959e3d46"
]
]
},
{
"id": "b4c01ef9959e3d46",
"type": "csv",
"z": "7f0acab470911e6e",
"name": "Convert to CSV",
"spec": "rfc",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "mult",
"ret": "\\r\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 780,
"y": 200,
"wires": [
[
"8bf7ab33a2355e9e"
]
]
},
{
"id": "8bf7ab33a2355e9e",
"type": "join",
"z": "7f0acab470911e6e",
"name": "",
"mode": "auto",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": false,
"accumulate": true,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 870,
"y": 120,
"wires": [
[
"564ee299fea9449b"
]
]
},
{
"id": "564ee299fea9449b",
"type": "file",
"z": "7f0acab470911e6e",
"name": "Save coops_507.csv",
"filename": "/home/mrosero/Documentos/mercadeo/coops/coops_507.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "true",
"encoding": "none",
"x": 1000,
"y": 40,
"wires": [
[
"ef9384e43a31a072"
]
]
},
{
"id": "d6845fd4ff25f851",
"type": "comment",
"z": "7f0acab470911e6e",
"name": "Cooperativas Leads",
"info": "### Fuente: IPCOOP",
"x": 110,
"y": 40,
"wires": []
},
{
"id": "df26defb28f7bf46",
"type": "file in",
"z": "7f0acab470911e6e",
"name": "Read Industrias (csv-raw)",
"filename": "/home/mrosero/Documentos/mercadeo/industria/mfg001_raw_507.csv",
"filenameType": "str",
"format": "lines",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": true,
"x": 370,
"y": 400,
"wires": [
[
"f4f8079998fb73d5"
]
]
},
{
"id": "144097555fbde30c",
"type": "inject",
"z": "7f0acab470911e6e",
"name": "Start",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 460,
"wires": [
[
"df26defb28f7bf46"
]
]
},
{
"id": "98fd8925d21c887b",
"type": "csv",
"z": "7f0acab470911e6e",
"name": "Set to CSV",
"spec": "rfc",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": true,
"include_null_values": false,
"x": 630,
"y": 480,
"wires": [
[
"29806b641ea02489"
]
]
},
{
"id": "29806b641ea02489",
"type": "function",
"z": "7f0acab470911e6e",
"name": "Fix Data",
"func": "var productos = \"\"\nvar sector = \"\"\nvar instagram = \"\"\nvar facebook = \"\"\nvar website = \"\"\nvar email = \"\"\nvar contact = \"\"\nvar industry = []\n\nlet emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nlet phoneRegex = /(\\+?\\d{1,4}[-.\\s]?)?(\\(?\\d{2,4}\\)?[-.\\s]?)?\\d{3,4}[-.\\s]?\\d{3,4}/g;\n \nif (msg.payload.Products.startsWith(\"Produce:\") ) {\n productos = msg.payload.Products.substring(9)\n}\n\nif (msg.payload.Products.startsWith(\"Sector:\") ) {\n sector=msg.payload['Products'].substring(8)\n}\n\nif (emailRegex.test(msg.payload['Female Employees Percentage'])) {\n email = msg.payload['Female Employees Percentage'];\n} \n\nif (emailRegex.test(msg.payload['Year Founded'])) {\n email = msg.payload['Year Founded'];\n}\n\nif (emailRegex.test(msg.payload['market'])) {\n email = msg.payload['market'];\n}\n\nif (emailRegex.test(msg.payload['Contact Information'])) {\n email = msg.payload['Contact Information'];\n}\n\nif (typeof msg.payload['email'] !== \"undefined\") {\n if (emailRegex.test(msg.payload['email'])) {\n email = msg.payload['email'];\n }\n}\n\nif (phoneRegex.test(msg.payload['Female Employees Percentage'])) {\n contact = msg.payload['Female Employees Percentage'];\n} \n\nif (phoneRegex.test(msg.payload['Year Founded'])) {\n contact = msg.payload['Year Founded'];\n}\n\nif (phoneRegex.test(msg.payload['market'])) {\n contact = msg.payload['market'];\n}\n\nif (typeof msg.payload['Contact Information'] !== \"undefined\") {\n if (phoneRegex.test(msg.payload['Contact Information'])) {\n contact = msg.payload['Contact Information'];\n }\n}\n\nif ( typeof msg.payload['Instagram Link'] !== \"undefined\" ) {\n if (msg.payload['Instagram Link'].search(\"instagram.com\") !== -1) {\n instagram = msg.payload['Instagram Link']\n } else if (msg.payload['Instagram Link'].search(\"facebook.com\") !== -1) {\n facebook = msg.payload['Instagram Link']\n } else {\n website = msg.payload['Instagram Link']\n }\n}\n\nif ( typeof msg.payload['Facebook Link'] !== \"undefined\" ) {\n if (msg.payload['Facebook Link'].search(\"instagram.com\") !== -1) {\n instagram = msg.payload['Facebook Link']\n } else if (msg.payload['Facebook Link'].search(\"facebook.com\") !== -1) {\n facebook = msg.payload['Facebook Link']\n } else {\n website = msg.payload['Facebook Link']\n }\n}\n\nindustry=[\n msg.payload['Position'],\n msg.payload['Company Name'].toLocaleUpperCase(),\n sector.replace(/\\b\\w+/g, word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()),\n productos.toLowerCase().replace(/(^|\\.\\s+)([a-z])/g, (match, sep, letter) => sep + letter.toUpperCase()),\n msg.payload['Company Size'],\n msg.payload['Number of Employees'],\n msg.payload['Location'],\n contact,\n email,\n website,\n instagram,\n facebook,\n msg.payload['Company Image'],\n]\n\nmsg.payload = industry;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 820,
"y": 440,
"wires": [
[
"5512e4f11e424bca"
]
]
},
{
"id": "7d2cd39e7bcf1c60",
"type": "file",
"z": "7f0acab470911e6e",
"name": "Save industrias",
"filename": "/home/mrosero/Documentos/mercadeo/industria/mfg001_507.csv",
"filenameType": "str",
"appendNewline": false,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 860,
"y": 580,
"wires": [
[
"043fa26ea24c4a85"
]
]
},
{
"id": "043fa26ea24c4a85",
"type": "debug",
"z": "7f0acab470911e6e",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 440,
"wires": []
},
{
"id": "f4f8079998fb73d5",
"type": "switch",
"z": "7f0acab470911e6e",
"name": "Clean empty record",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
}
],
"checkall": "true",
"repair": true,
"outputs": 1,
"x": 610,
"y": 400,
"wires": [
[
"d92b4c8ffab2ca69"
]
]
},
{
"id": "5512e4f11e424bca",
"type": "csv",
"z": "7f0acab470911e6e",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "mult",
"ret": "\\r\\n",
"temp": "",
"skip": "0",
"strings": false,
"include_empty_strings": false,
"include_null_values": "",
"x": 690,
"y": 620,
"wires": [
[
"7d2cd39e7bcf1c60"
]
]
},
{
"id": "d92b4c8ffab2ca69",
"type": "join",
"z": "7f0acab470911e6e",
"name": "",
"mode": "auto",
"build": "string",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": false,
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 430,
"y": 460,
"wires": [
[
"98fd8925d21c887b"
]
]
},
{
"id": "d83575dc7c3a1a52",
"type": "comment",
"z": "7f0acab470911e6e",
"name": "Industrias Leads",
"info": "### Fuente: MICI - Directorio de Empresas",
"x": 100,
"y": 360,
"wires": []
}
]