-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
31 lines (28 loc) · 838 Bytes
/
test.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
let axios = require('axios');
let cheerio = require('cheerio');
let base_url = 'http://www.bca.co.id/id/Individu/Sarana/Kurs-dan-Suku-Bunga/Kurs-dan-Kalkulator';
axios.get(base_url).then( (response) => {
let $ = cheerio.load(response.data);
let kurs = [];
$('tr', '.text-right').each( (i, elm) => {
kurs.push( {
currency: $(elm).children().first().text(),
erate: {
sell: $(elm).children().eq(1).first().text(),
buy: $(elm).children().eq(2).first().text()
},
tt: {
sell: $(elm).children().eq(3).first().text(),
buy: $(elm).children().eq(4).first().text()
},
notes: {
sell: $(elm).children().eq(5).first().text(),
buy: $(elm).children().eq(6).first().text()
}
});
});
return(kurs);
})
.then ( (kurs) => {
console.log(kurs);
});