-
Notifications
You must be signed in to change notification settings - Fork 1
/
markets.js
39 lines (31 loc) · 881 Bytes
/
markets.js
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
const rp = require('request-promise');
const _ = require('lodash');
const request = require('request');
const fs = require('fs');
var options = {
uri: 'http://smartweb.live/markets.json',
headers: {
'User-Agent': 'Request-Promise'
},
json: true // Automatically parses the JSON string in the response
};
rp(options).then(function (body) {
if(_.isObject(body)){
fs.writeFile(__dirname + "/markets/cloud.json", JSON.stringify(body), function (err) {
if (err)
return console.log(err);
console.log('Load Markets');
});
}
});
setInterval(function(){
rp(options).then(function (body) {
if(_.isObject(body)){
fs.writeFile(__dirname + "/markets/cloud.json", JSON.stringify(body), function (err) {
if (err)
return console.log("Null");
console.log('Load Markets');
});
}
});
},1000*120);