-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (33 loc) · 935 Bytes
/
Copy pathapp.js
File metadata and controls
41 lines (33 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Rajada de request com delay
// delay request promise array
var rp = require('request-promise-native');
const fs = require('fs');
var start = 82000
var end = 83000
var cpf = ''
var gap = 200
uri = 'http://www.omniinformatica.com.br/omnios/firebird_busca.inc.php?os_cpf='+cpf+'&os_num='
// rp(uri+n)
let data = Array.apply(null, Array(end-start)).map((x,index)=> start+index).map((n,index) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
rp(uri+n)
.then(x => {
console.log('\n--------------------')
console.log('N...'+n)
console.log('Value...'+x)
console.log('--------------------\n')
resolve(x)
})
.catch(err => reject(err))
}, index*gap)
})
})
Promise.all(data)
.then(value => {
fs.writeFile('array.txt', value, function (err) {
if (err) throw err;
console.log('Saved!');
});
})
.catch(err => console.log(err))