[ { "id": "7f0acab470911e6e", "type": "tab", "label": "Local Leads 507", "disabled": false, "info": "", "env": [] }, { "id": "ae43dc9d802ec4d9", "type": "tab", "label": "Flow 1", "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": "From 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": "Coops", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "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": 830, "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": 960, "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": "utf8", "chunk": false, "sendError": false, "encoding": "none", "allProps": true, "x": 270, "y": 740, "wires": [ [ "5512e4f11e424bca" ] ] }, { "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": 130, "y": 680, "wires": [ [ "df26defb28f7bf46" ] ] }, { "id": "29806b641ea02489", "type": "function", "z": "7f0acab470911e6e", "name": "Fix Data", "func": "var productos = \"\";\nvar contact = \"\";\nvar sector = \"\";\nvar instagram = \"\";\nvar facebook = \"\";\nvar website = \"\";\nvar email = \"\";\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(\"Sector\") ) {\n sector=msg.payload['Products'].substring(8);\n} else {\n if (msg.payload['Products'].startsWith(\"Produce\")) {\n productos = msg.payload['Products'].substring(9)\n } else {\n productos = msg.payload['Products'];\n }\n}\n\nif (emailRegex.test(msg.payload['Email'])) {\n email = msg.payload['Email'];\n}\n\nif (emailRegex.test(msg.payload['Contact Information'])) {\n email = msg.payload['Contact Information'];\n} else {\n contact = msg.payload['Contact Information']\n}\n\nif (msg.payload['Instagram Link'] == \"null\") {\n msg.payload['Instagram Link'] = \"\";\n};\n\nif (msg.payload['Facebook Link'] == \"null\") {\n msg.payload['Facebook Link'] = \"\";\n};\n\nif (msg.payload['Company Details Link'] == \"null\") {\n msg.payload['Company Details Link'] = \"\";\n};\n\nif (msg.payload['Instagram Link'].search(\"instagram\") == -1) {\n if (msg.payload['Instagram Link'].search(\"facebook\") == -1) {\n website = msg.payload['Instagram Link'];\n } else {\n facebook = msg.payload['Instagram Link'];\n }\n} else {\n instagram = msg.payload['Instagram Link'];\n};\n\nif (msg.payload['Facebook Link'].search(\"facebook\") == -1) { \n if (msg.payload['Facebook Link'].search(\"instagram\") == -1) {\n if (website == \"\") {\n website = msg.payload['Facebook Link'];\n } \n } else {\n if (instagram == \"\") {\n instagram = msg.payload['Facebook Link'];\n }\n }\n} else {\n facebook = msg.payload['Facebook Link'];\n};\n\nvar industry = {\n \"Position\": msg.payload['Position'],\n \"Company Name\": msg.payload['Company Name'].toLocaleUpperCase(),\n \"Sector\": sector.replace(/\\b\\w+/g, word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()),\n \"Products\": productos.toLowerCase().replace(/(^|\\.\\s+)([a-z])/g, (match, sep, letter) => sep + letter.toUpperCase()),\n \"Company Size\": msg.payload['Company Size'],\n \"Number of Employees\": msg.payload['Number of Employees'],\n \"Location\": msg.payload['Location'],\n \"Contact Information\": contact,\n \"Email\": email,\n \"Website URL\": website,\n \"Instagram Link\": instagram,\n \"Facebook Link\": facebook,\n \"Company Details Link\": msg.payload['Company Details Link'],\n \"Company Image\": msg.payload['Company Image']\n};\n\nmsg.payload = {};\nmsg.payload = industry;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 580, "y": 680, "wires": [ [ "d92b4c8ffab2ca69" ] ] }, { "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": "true", "encoding": "none", "x": 900, "y": 740, "wires": [ [ "043fa26ea24c4a85" ] ] }, { "id": "043fa26ea24c4a85", "type": "debug", "z": "7f0acab470911e6e", "name": "industrias", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1040, "y": 680, "wires": [] }, { "id": "5512e4f11e424bca", "type": "csv", "z": "7f0acab470911e6e", "name": "Get 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": true, "x": 480, "y": 740, "wires": [ [ "29806b641ea02489" ] ] }, { "id": "d83575dc7c3a1a52", "type": "comment", "z": "7f0acab470911e6e", "name": "Industrias Leads", "info": "### Fuente: MICI - Directorio de Empresas", "x": 140, "y": 320, "wires": [] }, { "id": "569e579e486cbf1f", "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": 130, "y": 460, "wires": [ [ "1a3ddb45b2149290" ] ] }, { "id": "1a3ddb45b2149290", "type": "http request", "z": "7f0acab470911e6e", "name": "Get BrowseAI Tasks List", "method": "GET", "ret": "obj", "paytoqs": "ignore", "url": "https://api.browse.ai/v2/robots/6b541bba-036a-49cd-9268-fa76a2480371/tasks?page=1", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "bearer", "senderr": false, "headers": [ { "keyType": "Content-Type", "keyValue": "", "valueType": "application/json", "valueValue": "" } ], "x": 210, "y": 580, "wires": [ [ "52965cb5601ee4a4" ] ] }, { "id": "04ba386d856493bd", "type": "debug", "z": "7f0acab470911e6e", "name": "industrias (raw)", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1020, "y": 580, "wires": [] }, { "id": "52965cb5601ee4a4", "type": "function", "z": "7f0acab470911e6e", "name": "Get Last Task URL", "func": "var index = msg.payload.result.robotTasks.totalCount - 1;\nmsg.url = msg.payload.result.robotTasks.items[index].capturedDataTemporaryUrl;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 450, "y": 580, "wires": [ [ "fc19a6825baae116" ] ] }, { "id": "05b7e66417dd4ae7", "type": "comment", "z": "7f0acab470911e6e", "name": "Get Company List (Browse AI)", "info": "### Fuente: MICI - Directorio de Empresas", "x": 360, "y": 460, "wires": [] }, { "id": "be847922faca4cf9", "type": "comment", "z": "7f0acab470911e6e", "name": "Local Company List (Fix)", "info": "### Fuente: MICI - Directorio de Empresas", "x": 350, "y": 680, "wires": [] }, { "id": "fc19a6825baae116", "type": "http request", "z": "7f0acab470911e6e", "name": "Get Last Task", "method": "GET", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [ { "keyType": "Content-Type", "keyValue": "", "valueType": "application/json", "valueValue": "" } ], "x": 320, "y": 520, "wires": [ [ "d5fbf9247f3d134b" ] ] }, { "id": "d5fbf9247f3d134b", "type": "change", "z": "7f0acab470911e6e", "name": "Get Company Directory", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "payload.capturedLists['Company Directory']", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 650, "y": 520, "wires": [ [ "0c2d05578bfc4ffa" ] ] }, { "id": "0c2d05578bfc4ffa", "type": "csv", "z": "7f0acab470911e6e", "name": "To CSV", "spec": "rfc", "sep": ",", "hdrin": "", "hdrout": "once", "multi": "mult", "ret": "\\r\\n", "temp": "", "skip": "0", "strings": true, "include_empty_strings": "", "include_null_values": "", "x": 780, "y": 580, "wires": [ [ "701633f3bdf43c9f" ] ] }, { "id": "701633f3bdf43c9f", "type": "file", "z": "7f0acab470911e6e", "name": "Save industrias (csv-raw)", "filename": "/home/mrosero/Documentos/mercadeo/industria/mfg001_raw_507.csv", "filenameType": "str", "appendNewline": false, "createDir": false, "overwriteFile": "false", "encoding": "none", "x": 970, "y": 520, "wires": [ [ "04ba386d856493bd" ] ] }, { "id": "d92b4c8ffab2ca69", "type": "join", "z": "7f0acab470911e6e", "name": "", "mode": "auto", "build": "array", "property": "payload", "propertyType": "msg", "key": "topic", "joiner": "\\n", "joinerType": "str", "useparts": true, "accumulate": false, "timeout": "", "count": "", "reduceRight": false, "reduceExp": "", "reduceInit": "", "reduceInitType": "num", "reduceFixup": "", "x": 810, "y": 680, "wires": [ [ "6747a41997739b16" ] ] }, { "id": "6747a41997739b16", "type": "csv", "z": "7f0acab470911e6e", "name": "To CSV", "spec": "rfc", "sep": ",", "hdrin": "", "hdrout": "all", "multi": "mult", "ret": "\\r\\n", "temp": "Position,Company Name,Sector,Products,Location,Company Size,Number of Employees,Contact Information,Email,Company Details Link,Company Image,Instagram Link,Facebook Link,Website URL", "skip": "0", "strings": true, "include_empty_strings": "", "include_null_values": "", "x": 710, "y": 740, "wires": [ [ "7d2cd39e7bcf1c60" ] ] }, { "id": "9efaa84d2b3edb26", "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": 350, "y": 380, "wires": [ [ "3b937e6b06c3278d" ] ] }, { "id": "3b937e6b06c3278d", "type": "http request", "z": "7f0acab470911e6e", "name": "Browse AI Status", "method": "GET", "ret": "txt", "paytoqs": "ignore", "url": "https://api.browse.ai/v2/status", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "bearer", "senderr": false, "headers": [], "x": 510, "y": 400, "wires": [ [ "1d3199e999f849ac" ] ] }, { "id": "1d3199e999f849ac", "type": "debug", "z": "7f0acab470911e6e", "name": "Status", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 690, "y": 360, "wires": [] }, { "id": "423c04669f93f87f", "type": "comment", "z": "7f0acab470911e6e", "name": "Palataform Status", "info": "", "x": 150, "y": 380, "wires": [] } ]