|
|
@ -5,16 +5,16 @@ var ref = 9.4; |
|
|
|
var LastRefDate = new Date(); |
|
|
|
var LastRefDate = new Date(); |
|
|
|
const thre = 0.2; |
|
|
|
const thre = 0.2; |
|
|
|
const maxDays = 5; |
|
|
|
const maxDays = 5; |
|
|
|
const checkInterval = 1000*60*5; |
|
|
|
const checkInterval = 1000//*60*5;
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(()=>{ |
|
|
|
setInterval(()=>{ |
|
|
|
getRate("GBP", "CNY", (rate)=>{ |
|
|
|
getRate("GBP", "CNY", (rate)=>{ |
|
|
|
console.log((new Date()) + " - GBP->CNY :: " + rate + " ref: " + ref); |
|
|
|
console.log((new Date()) + " - GBP->CNY :: " + rate + " ref: " + ref); |
|
|
|
if(rate < ref - thre){ |
|
|
|
if(rate < ref - thre){ |
|
|
|
console.log("GBP DOWN!!"); |
|
|
|
console.log("GBP DOWN!!"); |
|
|
|
mail("i@yimian.xyz", `GBP DOWN TO ${rate}`, `Current Rate: ${rate}, Ref Rate: ${ref}`); |
|
|
|
//mail("i@yimian.xyz", `GBP DOWN TO ${rate}`, `Current Rate: ${rate}, Ref Rate: ${ref}`);
|
|
|
|
sms("18118155257", `英镑跌至${rate}`, `发消息提醒`); |
|
|
|
//sms("18118155257", `英镑跌至${rate}`, `发消息提醒`);
|
|
|
|
sms("15827586269", `英镑跌至${rate}`, `发消息提醒`); |
|
|
|
//sms("15827586269", `英镑跌至${rate}`, `发消息提醒`);
|
|
|
|
ref = rate; |
|
|
|
ref = rate; |
|
|
|
LastRefDate = new Date(); |
|
|
|
LastRefDate = new Date(); |
|
|
|
} |
|
|
|
} |
|
|
@ -28,12 +28,10 @@ setInterval(()=>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getRate = (from = "GBP", to = "CNY", callback) => { |
|
|
|
var getRate = (from = "GBP", to = "CNY", callback) => { |
|
|
|
request(`https://webapi.huilv.cc/api/exchange?num=100&chiyouhuobi=${from}&duihuanhuobi=${to}`, function (error, response, body) { |
|
|
|
request(`https://www.huilv.cc/${from}_${to}/`, function (error, response, body) { |
|
|
|
if (error) console.log('error:', error); // Print the error if one occurred
|
|
|
|
if (error) console.log('error:', error); // Print the error if one occurred
|
|
|
|
var jisuanjieguo = (res) => { |
|
|
|
var erate = body.match(/<span(.*?)<\/span>/g)[0].match(/\d+(.\d+)?/g)[0]; |
|
|
|
return res.dangqianhuilv; |
|
|
|
console.log(erate); |
|
|
|
}; |
|
|
|
|
|
|
|
var erate = eval(body); |
|
|
|
|
|
|
|
callback(erate); |
|
|
|
callback(erate); |
|
|
|
});} |
|
|
|
});} |
|
|
|
|
|
|
|
|
|
|
|