I want to create or write new files from the screenshots taken with Puppeteer, but it won't work unless I overwrite them. What I desire is for the Node to write/create new files with the actual timestamp when the screenshot is taken.
Installed Node : @digitalnodecom/node-red-contrib-puppeteer
node red version : 3.1.0
node js version : 20.9.0
below is my flow :
[
{
"id": "f8bf1613b88e2463",
"type": "tab",
"label": "Flow 4",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c75fd69fd380cec7",
"type": "inject",
"z": "f8bf1613b88e2463",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 160,
"wires": [
[
"75e9c362a92ed018"
]
]
},
{
"id": "75e9c362a92ed018",
"type": "puppeteer-browser-launch",
"z": "f8bf1613b88e2463",
"timeout": 30000,
"slowMo": 0,
"headless": true,
"debugport": 0,
"devtools": false,
"cookies": "",
"name": "",
"x": 280,
"y": 160,
"wires": [
[
"021ee836ddbaab41"
]
]
},
{
"id": "021ee836ddbaab41",
"type": "puppeteer-page-goto",
"z": "f8bf1613b88e2463",
"name": "",
"url": "https://lmarkrol.web.app",
"urltype": "str",
"waitUntil": "networkidle2",
"x": 490,
"y": 160,
"wires": [
[
"033d8ab932f32121"
]
]
},
{
"id": "033d8ab932f32121",
"type": "puppeteer-page-screenshot",
"z": "f8bf1613b88e2463",
"name": "",
"fullpage": true,
"x": 130,
"y": 220,
"wires": [
[
"4ddb6b6db5c5f448"
]
]
},
{
"id": "4ddb6b6db5c5f448",
"type": "function",
"z": "f8bf1613b88e2463",
"name": "rename",
"func": "msg.payload = \"screenshot_\" + Date.now() + \".jpg\";\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 220,
"wires": [
[
"41cf289c49d28d78"
]
]
},
{
"id": "2643e641bf611291",
"type": "puppeteer-browser-close",
"z": "f8bf1613b88e2463",
"name": "",
"x": 800,
"y": 220,
"wires": [
[]
]
},
{
"id": "41cf289c49d28d78",
"type": "file",
"z": "f8bf1613b88e2463",
"name": "",
"filename": "D:/Pictures/[SS]",
"filenameType": "str",
"appendNewline": false,
"createDir": true,
"overwriteFile": "false",
"encoding": "utf8",
"x": 540,
"y": 320,
"wires": [
[
"2643e641bf611291"
]
]
}
]