updated data and fixed retriever
This commit is contained in:
parent
1995c45823
commit
0b3e254bb7
32
app.js
32
app.js
@ -1,24 +1,22 @@
|
|||||||
const loader = require('./libs/loader');
|
const loader = require("./libs/loader");
|
||||||
const lot = require('./libs/lot');
|
const lot = require("./libs/lot");
|
||||||
const lotv2 = require('./libs/lotV2');
|
const lotv2 = require("./libs/lotV2");
|
||||||
const pusher = require('./libs/pusher');
|
const pusher = require("./libs/pusher");
|
||||||
const log4js = require('log4js');
|
const log4js = require("log4js");
|
||||||
const logger = log4js.getLogger();
|
const logger = log4js.getLogger();
|
||||||
const cron = require('node-cron');
|
const cron = require("node-cron");
|
||||||
|
|
||||||
const {retrieveNew} = require('./libs/retriever');
|
const { retrieveNew } = require("./libs/retriever");
|
||||||
|
|
||||||
logger.level = 'debug';
|
logger.level = "debug";
|
||||||
|
|
||||||
function run(data) {
|
function run(data) {
|
||||||
const v1 = lot.calculate(data);
|
const v1 = lot.calculate(data);
|
||||||
const v2 = lotv2.calculate(data);
|
const v2 = lotv2.calculate(data);
|
||||||
|
|
||||||
const msg =
|
const msg = `V2: ${v2} stars: ${v1.mainstars}
|
||||||
|
|
||||||
`V2: ${v2} stars: ${v1.mainstars}
|
|
||||||
V1: ${v1.mainline} stars: ${v1.mainstars}
|
V1: ${v1.mainline} stars: ${v1.mainstars}
|
||||||
Other: ${v1.otherLine} stars: ${v1.otherStars}
|
Other: ${v1.otherLine} stars: ${v1.otherStars}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
pusher.push(msg);
|
pusher.push(msg);
|
||||||
@ -27,21 +25,21 @@ Other: ${v1.otherLine} stars: ${v1.otherStars}
|
|||||||
}
|
}
|
||||||
|
|
||||||
function go() {
|
function go() {
|
||||||
logger.info('GO!');
|
logger.info("GO!");
|
||||||
loader.load(run);
|
loader.load(run);
|
||||||
|
retrieveNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
cron.schedule('10 15 * * 2,5', () => {
|
cron.schedule("10 15 * * 2,5", () => {
|
||||||
go();
|
go();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
cron.schedule('45 9 * * 3,6', () => {
|
cron.schedule("45 9 * * 3,6", () => {
|
||||||
retrieveNew();
|
retrieveNew();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info('Lot V3 started...');
|
logger.info("Lot V3 started...");
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,33 +1,34 @@
|
|||||||
const jsonfile = require('jsonfile');
|
const jsonfile = require("jsonfile");
|
||||||
|
|
||||||
const fetch = require('node-fetch');
|
const fetch = require("node-fetch");
|
||||||
const fecha = require('fecha');
|
const fecha = require("fecha");
|
||||||
|
|
||||||
const { scrapeResults } = require('./scraper');
|
const { scrapeResults } = require("./scraper");
|
||||||
|
|
||||||
const file = 'data/data.json';
|
const file = "data/data.json";
|
||||||
|
|
||||||
// https://www.euro-millions.com/results
|
// https://www.euro-millions.com/results
|
||||||
|
|
||||||
function retrieveNew() {
|
function retrieveNew() {
|
||||||
|
console.log("retrieveNew...");
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
|
|
||||||
// https://www.euro-millions.com/results/05-02-2019
|
// https://www.euro-millions.com/results/05-02-2019
|
||||||
|
|
||||||
const yesterday = new Date(now - (8.64e+7));
|
const yesterday = new Date(now - 8.64e7);
|
||||||
|
|
||||||
const ystring = fecha.format(yesterday, '/DD-MM-YYYY');
|
const ystring = fecha.format(yesterday, "/DD-MM-YYYY");
|
||||||
|
|
||||||
const lotData = jsonfile.readFileSync(file);
|
const lotData = jsonfile.readFileSync(file);
|
||||||
const u = `https://www.euro-millions.com/results${ystring}`;
|
const u = `https://www.euro-millions.com/results${ystring}`;
|
||||||
|
|
||||||
console.log('retrieving:', u);
|
console.log("retrieving:", u);
|
||||||
|
|
||||||
// https://www.euro-millions.com/results/15-02-2019
|
// https://www.euro-millions.com/results/15-02-2019
|
||||||
|
|
||||||
fetch(u)
|
fetch(u)
|
||||||
.then(res => res.text())
|
.then((res) => res.text())
|
||||||
.then(body => {
|
.then((body) => {
|
||||||
const m = scrapeResults(body);
|
const m = scrapeResults(body);
|
||||||
|
|
||||||
console.log(m);
|
console.log(m);
|
||||||
|
@ -16,9 +16,9 @@ function scrapeResults(html) {
|
|||||||
|
|
||||||
outArray.push(fecha.format(newDate, 'YYYY-MM-DD'));
|
outArray.push(fecha.format(newDate, 'YYYY-MM-DD'));
|
||||||
|
|
||||||
const cells = $('#jsBallOrderCell li');
|
const cells = $('#ballsAscending li');
|
||||||
|
|
||||||
if ($(cells).length > 0)
|
if ($(cells).length > 0)
|
||||||
|
|
||||||
cells.each((i, item) => {
|
cells.each((i, item) => {
|
||||||
outArray.push(parseInt($(item).text(), 10));
|
outArray.push(parseInt($(item).text(), 10));
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node lot.js"
|
"start": "node lot.js",
|
||||||
|
"retrieve": "node app.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user