Yes, thats exactly what I'm saying!
Here's a real example of what that part of the flow looks like:
[
{
"id": "8a0ef51a775db706",
"type": "function",
"z": "2eae83f77d8ec666",
"name": "Förbereder googlehtml.js",
"func": "let url = msg.url;\n\nmsg.payload = `const puppeteer = require('puppeteer-extra');\nconst StealthPlugin = require('puppeteer-extra-plugin-stealth');\nconst AdblockerPlugin = require('puppeteer-extra-plugin-adblocker');\nconst fs = require('fs');\nconst fetch = require('node-fetch');\n\n// Använd plugin-programmen\npuppeteer.use(StealthPlugin());\npuppeteer.use(AdblockerPlugin({ blockTrackers: true }));\n\n(async () => {\n try {\n let browserWSEndpoint = '';\n await fetch(\"http://172.19.0.100:9222/json/version\")\n .then(response => response.json())\n .then(data => {\n browserWSEndpoint = data.webSocketDebuggerUrl;\n })\n .catch(error => console.error('Fel vid hämtning av browserWSEndpoint:', error));\n\n const browser = await puppeteer.connect({ browserWSEndpoint, ignoreHTTPSErrors: true });\n const page = await browser.newPage();\n\n await page.goto('${url}', { waitUntil: 'networkidle2' });\n\n const htmlContent = await page.content();\n fs.writeFileSync('/opt/node-red/temp/out.html', htmlContent);\n\n // Flytta stängningen av alla sidor hit, innan browser.close()\n const pages = await browser.pages();\n await Promise.all(pages.map(page => page.close()));\n\n await browser.close();\n } catch (error) {\n console.error('Ett oväntat fel uppstod:', error);\n }\n})();`;\n\nreturn msg;\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 1300,
"wires": [
[
"357edbfe0ad91ee0",
"ee647288aed249f0"
]
]
},
{
"id": "357edbfe0ad91ee0",
"type": "file",
"z": "2eae83f77d8ec666",
"name": "Skriver över kod till googlehtml.js",
"filename": "/opt/node-red/script/googlehtml.js",
"filenameType": "str",
"appendNewline": false,
"createDir": false,
"overwriteFile": "true",
"encoding": "none",
"x": 520,
"y": 1340,
"wires": [
[
"6c6246a25dd941de",
"16eb6e9cb91ab636"
]
]
},
{
"id": "ee647288aed249f0",
"type": "debug",
"z": "2eae83f77d8ec666",
"name": "Förbereder googlehtml.js",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1030,
"y": 1300,
"wires": []
},
{
"id": "6c6246a25dd941de",
"type": "debug",
"z": "2eae83f77d8ec666",
"name": "Skriver över kod till googlehtml.js",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 1340,
"wires": []
},
{
"id": "3c196409affb01d3",
"type": "debug",
"z": "2eae83f77d8ec666",
"name": "OUTPUT - Sparar ner Google HTML till /mnt/local/Media/test/temp/out.html",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 1360,
"wires": []
},
{
"id": "4764325e4be52e15",
"type": "debug",
"z": "2eae83f77d8ec666",
"name": "ERROR - Sparar ner Google HTML till /mnt/local/Media/test/temp/out.html",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1180,
"y": 1380,
"wires": []
},
{
"id": "d3da1bf50e397d43",
"type": "debug",
"z": "2eae83f77d8ec666",
"name": "EXIT - Sparar ner Google HTML till /mnt/local/Media/test/temp/out.html",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1170,
"y": 1400,
"wires": []
},
{
"id": "16eb6e9cb91ab636",
"type": "exec",
"z": "2eae83f77d8ec666",
"command": "node /opt/node-red/script/googlehtml.js",
"addpay": false,
"append": "",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "Sparar ner Google HTML till /opt/node-red/temp/out.html",
"x": 590,
"y": 1380,
"wires": [
[
"3c196409affb01d3",
"189c500d19f16f40"
],
[
"4764325e4be52e15"
],
[
"d3da1bf50e397d43"
]
]
}
]