Skip to content

Instantly share code, notes, and snippets.

@mdimai666
Created April 18, 2018 07:36
Show Gist options
  • Save mdimai666/be47df10ff5eee9a3e70b51172df92cc to your computer and use it in GitHub Desktop.
Save mdimai666/be47df10ff5eee9a3e70b51172df92cc to your computer and use it in GitHub Desktop.
[
{
"id": "179c3813.5b8248",
"type": "function",
"z": "f2af3e46.9dad5",
"name": "random url",
"func": "var ran = Math.random()*1000 | 0;\n// msg.url = 'https://www.google.ru/search?q='+ran+'&sourceid=chrome&ie=UTF-8';\n// msg.url = 'https://www.bing.com/search?q='+ran+'&sourceid=chrome&ie=UTF-8';\nmsg.url = 'http://randomtextgenerator.com/';\n\nmsg.payload = {\n text_mode: 'plain',\n language:'en',\n Go:'Go'\n}\nmsg.headers = {'Accept-Language':'en'};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 334,
"y": 868,
"wires": [
[
"40eb0d1f.d6f4c4"
]
]
},
{
"id": "dfd314d.734dfe8",
"type": "inject",
"z": "f2af3e46.9dad5",
"name": "get random text",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 156,
"y": 870,
"wires": [
[
"179c3813.5b8248"
]
]
},
{
"id": "40eb0d1f.d6f4c4",
"type": "http request",
"z": "f2af3e46.9dad5",
"name": "get random text from randomtext",
"method": "POST",
"ret": "txt",
"url": "",
"tls": "",
"x": 567.5,
"y": 870,
"wires": [
[
"95143875.f0e248"
]
]
},
{
"id": "95143875.f0e248",
"type": "cheerio",
"z": "f2af3e46.9dad5",
"name": "",
"tag": "body",
"ret": "object",
"as": "multi",
"map": [
{
"search": "#generatedtext",
"ret": "text",
"replace": "text",
"attr": ""
}
],
"xmlMode": false,
"decodeEntities": false,
"lowerCaseTags": false,
"lowerCaseAttributeNames": false,
"recognizeCDATA": false,
"recognizeSelfClosing": false,
"x": 788,
"y": 870,
"wires": [
[
"c0b18962.73e418"
]
]
},
{
"id": "c0b18962.73e418",
"type": "function",
"z": "f2af3e46.9dad5",
"name": "gen random emails",
"func": "var mailboxes = ['mail.ru','gmail.com','yandex.ru','sakha.gov.ru','probox.prg','zaq.qua'];\n\nvar count = 100;\n\nvar rtext = msg.payload;\nif(!rtext) return node.error('PAYLOAD is emty');\n\nif(typeof rtext === 'object')\n rtext = rtext.text;\n\nrtext=rtext.slice(0,3000);\n// rtext = preg_replace('[^a-zA-Z0-9.-]', '', $s);\nrtext = rtext.split(/[ ,.-]+/);\n\n\n\nvar data = [];\n\nfor(var i=0; i<count;i++){\n var r = R(rtext.length)\n var m = rtext[r];\n var b = mailboxes[R(mailboxes.length)];\n var y = randomYear();\n var mail = m+y+'@'+b;\n data.push(mail);\n}\n\nfunction randomYear(){\n return R(100)+1920;\n}\n\nfunction R(n){\n return Math.random()*n | 0;\n}\n\nmsg.payload= data;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 438,
"y": 930,
"wires": [
[
"c2930a07.196078",
"a0415d78.39c45"
]
]
},
{
"id": "c2930a07.196078",
"type": "debug",
"z": "f2af3e46.9dad5",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 714,
"y": 935,
"wires": []
},
{
"id": "a0415d78.39c45",
"type": "function",
"z": "f2af3e46.9dad5",
"name": "to Model.mails object",
"func": "let list = [];\n\nlet mails = msg.payload;\n\nmails.map(s=>{\n let email = {\n eto: s,\n efrom: '[email protected]',\n subject: 'subject -- ' + s,\n body: 'bidy body',\n id_campaigns: 25\n };\n list.push(email);\n});\n\nmsg.payload = list;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 371,
"y": 998,
"wires": [
[
"c5363192.bee5a",
"c2930a07.196078"
]
]
},
{
"id": "a3305624.f95808",
"type": "inject",
"z": "f2af3e46.9dad5",
"name": "text generate function",
"topic": "",
"payload": "ahefui hahfp adfjoaejf opaef",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 172,
"y": 924,
"wires": [
[
"c0b18962.73e418"
]
]
},
{
"id": "43c84c85.b0b514",
"type": "inject",
"z": "f2af3e46.9dad5",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 136,
"y": 997,
"wires": [
[
"a0415d78.39c45"
]
]
},
{
"id": "c5363192.bee5a",
"type": "http request",
"z": "f2af3e46.9dad5",
"name": "add to db",
"method": "POST",
"ret": "obj",
"url": "http://localhost:3050/api/mails/add/",
"tls": "",
"x": 593.5,
"y": 998,
"wires": [
[
"aa360c9a.58fac"
]
]
},
{
"id": "aa360c9a.58fac",
"type": "debug",
"z": "f2af3e46.9dad5",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 773,
"y": 995,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment