-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
91 lines (65 loc) · 2.34 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const express = require('express');
const request = require('request');
const cheerio = require('cheerio');
const app = express();
const EUROMILLIONS_URL = 'https://www.jogossantacasa.pt/web/SCCartazResult/';
const M1LHAO_URL = 'https://www.jogossantacasa.pt/web/SCCartazResult/m1lhao';
app.get('/', (req, res) => {
res.send('Server running');
});
app.get('/last', (req, res) => {
request(EUROMILLIONS_URL, (err, result, html) => {
const $ = cheerio.load(html);
let date = $('.dataInfo').text().split(' ')[7];
let key = $('.colums').find('li').first().text().split('+');
let balls = key[0].trimRight();
let stars = key[1].trimLeft();
let jackpot = $('.noLine').find('.stronger').last().text().trim();
request(M1LHAO_URL, (err, result, html) => {
const $ = cheerio.load(html);
let code = $('#code_m1').text();
let codeDate = $('.dataInfo').text().split(' ')[7];
const sendKey = {
date: date,
balls: balls,
stars: stars,
jackpot: jackpot,
milhaoCode: code,
milhaoDate: codeDate
};
res.send(sendKey);
});
});
});
app.get('/euro', (req, res) => {
request(EUROMILLIONS_URL, (err, result, html) => {
const $ = cheerio.load(html);
let date = $('.dataInfo').text().split(' ')[7];
let key = $('.colums').find('li').first().text().split('+');
let balls = key[0].trimRight();
let stars = key[1].trimLeft();
let jackpot = $('.noLine').find('.stronger').last().text().trim();
const sendKey = {
date: date,
balls: balls,
stars: stars,
jackpot: jackpot
};
res.send(sendKey)
});
});
app.get('/milhao', (req, res) => {
request('https://www.jogossantacasa.pt/web/SCCartazResult/m1lhao', (err, result, html) => {
const $ = cheerio.load(html);
let code = $('#code_m1').text()
let codeDate = $('.dataInfo').text().split(' ')[7];
const getM1lhao = {
code: code,
code_date: codeDate
};
res.send(getM1lhao);
});
});
app.listen(3000, () => {
console.log("Listenning")
});