Created
July 10, 2018 08:45
-
-
Save mdimai666/79cf5a15e986001a6b85528bee0b012e to your computer and use it in GitHub Desktop.
gist parst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "1f26139b.0b994c", | |
| "type": "debug", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "active": true, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "false", | |
| "x": 749, | |
| "y": 689, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "26c8d280.d4653e", | |
| "type": "template", | |
| "z": "fc469f5.4b34b6", | |
| "name": "complete text", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "Complete!! {{payload2.length}} !", | |
| "output": "str", | |
| "x": 768, | |
| "y": 617, | |
| "wires": [ | |
| [ | |
| "1f26139b.0b994c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "46fa0c5c.1d3c94", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "func": "var a = [];\n\n// for(var e of msg.payload)\n // a.concat(e)\nmsg.payload.map(s=>{a = a.concat(s)});\nmsg.payload = a;\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 430, | |
| "y": 1000, | |
| "wires": [ | |
| [ | |
| "78778e67.9f2ad", | |
| "1f26139b.0b994c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d795b606.40eca8", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "loop", | |
| "func": "if(msg.loop_array.length<1)\n return [null,msg];\n \nmsg.loop_current = msg.loop_array.shift();\nmsg.payload = msg.loop_current;\n\nnode.status({text:`${msg.payload}/${msg.loop_array_count}`})\n\nreturn [msg]", | |
| "outputs": 2, | |
| "noerr": 0, | |
| "x": 417, | |
| "y": 318, | |
| "wires": [ | |
| [ | |
| "54e1eacb.67e9f4" | |
| ], | |
| [ | |
| "26c8d280.d4653e", | |
| "6bd5b373.c22f3c" | |
| ] | |
| ], | |
| "outputLabels": [ | |
| "iteration", | |
| "end" | |
| ], | |
| "icon": "node-red/cog.png" | |
| }, | |
| { | |
| "id": "133ed1d0.c20e9e", | |
| "type": "json", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 510, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "46fa0c5c.1d3c94" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "78778e67.9f2ad", | |
| "type": "file", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "filename": "C:\\\\node\\\\test\\\\questions-2.json", | |
| "appendNewline": true, | |
| "createDir": false, | |
| "overwriteFile": "true", | |
| "x": 651, | |
| "y": 1137, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "24aef0ac.9653", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "init loop", | |
| "func": "msg.loop_array = msg.payload;\nmsg.loop_array_count = msg.payload.length;\nmsg.loop_array_save = msg.payload;\nmsg.loop_dt_start = new Date();\n\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 258, | |
| "y": 319, | |
| "wires": [ | |
| [ | |
| "d795b606.40eca8" | |
| ] | |
| ], | |
| "icon": "node-red/cog.png" | |
| }, | |
| { | |
| "id": "54e1eacb.67e9f4", | |
| "type": "change", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "url", | |
| "pt": "msg", | |
| "to": "payload", | |
| "tot": "msg" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 607, | |
| "y": 316, | |
| "wires": [ | |
| [ | |
| "2cb6ed9a.f89302" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5ea4294.5ff61d8", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "func": "if(!msg.payload2) msg.payload2 = [];\nmsg.payload2.push(msg.payload);\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 439, | |
| "y": 646, | |
| "wires": [ | |
| [ | |
| "d795b606.40eca8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "6bd5b373.c22f3c", | |
| "type": "change", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "payload2", | |
| "tot": "msg" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 547, | |
| "y": 781, | |
| "wires": [ | |
| [ | |
| "d3cfc0ed.39a22" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "31534f38.5383d", | |
| "type": "file in", | |
| "z": "fc469f5.4b34b6", | |
| "name": "questions.json", | |
| "filename": "C:\\\\node\\\\test\\\\questions.json", | |
| "format": "utf8", | |
| "chunk": false, | |
| "sendError": false, | |
| "x": 320, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "133ed1d0.c20e9e" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "9c081018.7a3eb", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "fill range 301", | |
| "func": "var a = [];\nfor(var i=1;i<=301;i++)\n a.push(i);\n \nmsg.payload = a;\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 307, | |
| "y": 238, | |
| "wires": [ | |
| [ | |
| "24aef0ac.9653" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "2cb6ed9a.f89302", | |
| "type": "template", | |
| "z": "fc469f5.4b34b6", | |
| "name": "url", | |
| "field": "url", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "https://baza-otvetov.ru/categories/view/1/{{payload}}", | |
| "output": "str", | |
| "x": 254, | |
| "y": 470, | |
| "wires": [ | |
| [ | |
| "c31a23dc.3dede" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "860638f1.590d28", | |
| "type": "join", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "mode": "auto", | |
| "build": "string", | |
| "property": "payload", | |
| "propertyType": "msg", | |
| "key": "topic", | |
| "joiner": "\\n", | |
| "joinerType": "str", | |
| "accumulate": "false", | |
| "timeout": "", | |
| "count": "", | |
| "reduceRight": false, | |
| "x": 510, | |
| "y": 522, | |
| "wires": [ | |
| [ | |
| "5ea4294.5ff61d8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d3cfc0ed.39a22", | |
| "type": "file", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "filename": "C:\\\\node\\\\test\\\\questions.json", | |
| "appendNewline": true, | |
| "createDir": false, | |
| "overwriteFile": "true", | |
| "x": 777, | |
| "y": 782, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "3ab18902.4102b6", | |
| "type": "inject", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "x": 140, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "31534f38.5383d" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e64f318e.8ae55", | |
| "type": "inject", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "topic": "", | |
| "payload": "1", | |
| "payloadType": "num", | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "x": 128, | |
| "y": 232, | |
| "wires": [ | |
| [ | |
| "9c081018.7a3eb" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "c31a23dc.3dede", | |
| "type": "http request", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "method": "GET", | |
| "ret": "txt", | |
| "url": "", | |
| "tls": "", | |
| "x": 402, | |
| "y": 473, | |
| "wires": [ | |
| [ | |
| "634c0620.8821c8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "3dec5515.a196ca", | |
| "type": "function", | |
| "z": "fc469f5.4b34b6", | |
| "name": "normalize", | |
| "func": "var p = msg.payload;\n\np.question = p.question.trim();\n\np.answers = p.answers.trim().slice(\"Ответы для викторин: \".length).split(',').map(s=>s.trim());\n\np.answer = p.answer.trim();\n\np.answers = [p.answer].concat(p.answers);\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 382, | |
| "y": 523, | |
| "wires": [ | |
| [ | |
| "860638f1.590d28" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "634c0620.8821c8", | |
| "type": "cheerio", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "tag": ".q-list__table tr", | |
| "ret": "object", | |
| "as": "single", | |
| "map": [ | |
| { | |
| "search": "td a", | |
| "ret": "text", | |
| "replace": "question", | |
| "attr": "" | |
| }, | |
| { | |
| "search": "td .q-list__quiz-answers", | |
| "ret": "text", | |
| "replace": "answers", | |
| "attr": "" | |
| }, | |
| { | |
| "search": "td:last-child", | |
| "ret": "text", | |
| "replace": "answer", | |
| "attr": "" | |
| } | |
| ], | |
| "xmlMode": false, | |
| "decodeEntities": false, | |
| "lowerCaseTags": false, | |
| "lowerCaseAttributeNames": false, | |
| "recognizeCDATA": false, | |
| "recognizeSelfClosing": false, | |
| "x": 566, | |
| "y": 475, | |
| "wires": [ | |
| [ | |
| "41ca8d2b.e5af54" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "41ca8d2b.e5af54", | |
| "type": "split", | |
| "z": "fc469f5.4b34b6", | |
| "name": "", | |
| "splt": "\\n", | |
| "spltType": "str", | |
| "arraySplt": 1, | |
| "arraySpltType": "len", | |
| "stream": false, | |
| "addname": "", | |
| "x": 245, | |
| "y": 517, | |
| "wires": [ | |
| [ | |
| "3dec5515.a196ca" | |
| ] | |
| ] | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment