Advertisement
NittyGritty

Get Pellet Price from https://www.holzpellets.net/pelletspreise/

May 31st, 2023
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.94 KB | Source Code | 0 0
  1. [
  2.     {
  3.         "id": "f88dc0dd72cd0a25",
  4.         "type": "inject",
  5.         "z": "dabdc8fc290e3b36",
  6.         "name": "",
  7.         "props": [
  8.             {
  9.                 "p": "payload"
  10.             },
  11.             {
  12.                 "p": "topic",
  13.                 "vt": "str"
  14.             }
  15.         ],
  16.         "repeat": "",
  17.         "crontab": "",
  18.         "once": false,
  19.         "onceDelay": 0.1,
  20.         "topic": "",
  21.         "payload": "",
  22.         "payloadType": "date",
  23.         "x": 140,
  24.         "y": 300,
  25.         "wires": [
  26.             [
  27.                 "32132abba67ed588"
  28.             ]
  29.         ]
  30.     },
  31.     {
  32.         "id": "32132abba67ed588",
  33.         "type": "http request",
  34.         "z": "dabdc8fc290e3b36",
  35.         "name": "",
  36.         "method": "GET",
  37.         "ret": "txt",
  38.         "paytoqs": "ignore",
  39.         "url": "https://www.holzpellets.net/pelletspreise/",
  40.         "tls": "",
  41.         "persist": false,
  42.         "proxy": "",
  43.         "insecureHTTPParser": false,
  44.         "authType": "",
  45.         "senderr": false,
  46.         "headers": [],
  47.         "x": 370,
  48.         "y": 300,
  49.         "wires": [
  50.             [
  51.                 "7c04d5770e17ef16",
  52.                 "f266365a77668506"
  53.             ]
  54.         ]
  55.     },
  56.     {
  57.         "id": "7c04d5770e17ef16",
  58.         "type": "html",
  59.         "z": "dabdc8fc290e3b36",
  60.         "name": "",
  61.         "property": "payload",
  62.         "outproperty": "payload",
  63.         "tag": "p",
  64.         "ret": "html",
  65.         "as": "single",
  66.         "x": 550,
  67.         "y": 300,
  68.         "wires": [
  69.             [
  70.                 "0fc5234932db8552"
  71.             ]
  72.         ]
  73.     },
  74.     {
  75.         "id": "0fc5234932db8552",
  76.         "type": "function",
  77.         "z": "dabdc8fc290e3b36",
  78.         "name": "function 5",
  79.         "func": "var EuroPos=0;\nvar DatumPos=0\nvar count=0;\n\n// find Pragraph containing Euro Price\n\nfor (var i = 0; i < 30; i++) {\n    if (msg.payload[i].includes(\"Bundesweite Holzpelletspreise\")) {\n        break;\n        }\n    else\n     { count++;}\n}\n\nEuroPos = count+1;\nDatumPos= count+2;\n\n// var EuroPos = 18;\n// var DatumPos = 19\n\nvar words = msg.payload[EuroPos].split(' ');\nvar Preis = (words[0]) + \" Euro\";\n\nwords = msg.payload[DatumPos].split(',');\nvar Datum = words[0];\n\nvar Zeit = words[1];\nwords = Zeit.split(' ');\nZeit = words[1] + \":00\";\n\nvar pattern = /(\\d{2})\\.(\\d{2})\\.(\\d{4})/;\nvar dt = Datum.replace(pattern, '$3-$2-$1') + \" \" + Zeit;\n// var dt = new Date(Datum.replace(pattern, '$3-$2-$1') + Zeit );\ndt = new Date(dt);\n\nnode.status({\n    fill: \"green\",\n    shape: \"ring\",\n    text:   \"Preis: \" + Preis +\n            \", Datum: \" + Datum +\n            \", Zeit: \" + Zeit +\n            \", Count: \" + count\n});\n\n\nreturn [{payload:Preis}, {payload:dt}];",
  80.         "outputs": 2,
  81.         "noerr": 0,
  82.         "initialize": "",
  83.         "finalize": "",
  84.         "libs": [],
  85.         "x": 720,
  86.         "y": 300,
  87.         "wires": [
  88.             [
  89.                 "e5cbb3eee7041f2b"
  90.             ],
  91.             [
  92.                 "8ddc1085d9f840e4"
  93.             ]
  94.         ]
  95.     },
  96.     {
  97.         "id": "e5cbb3eee7041f2b",
  98.         "type": "debug",
  99.         "z": "dabdc8fc290e3b36",
  100.         "name": "debug 10",
  101.         "active": true,
  102.         "tosidebar": false,
  103.         "console": false,
  104.         "tostatus": true,
  105.         "complete": "payload",
  106.         "targetType": "msg",
  107.         "statusVal": "payload",
  108.         "statusType": "auto",
  109.         "x": 940,
  110.         "y": 220,
  111.         "wires": []
  112.     },
  113.     {
  114.         "id": "8ddc1085d9f840e4",
  115.         "type": "debug",
  116.         "z": "dabdc8fc290e3b36",
  117.         "name": "debug 12",
  118.         "active": true,
  119.         "tosidebar": false,
  120.         "console": false,
  121.         "tostatus": true,
  122.         "complete": "payload",
  123.         "targetType": "msg",
  124.         "statusVal": "payload",
  125.         "statusType": "auto",
  126.         "x": 940,
  127.         "y": 280,
  128.         "wires": []
  129.     }
  130. ]
Tags: nodered
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement