-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverificarPrecoSMS.js
48 lines (40 loc) · 1.61 KB
/
verificarPrecoSMS.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
const axios = require('axios');
getPrices();
async function getPrices() {
for (let i = 1; i <= 201; i++) {
await new Promise(function (resolve) { setTimeout(resolve, 100) });
await getPriceGoole(i);
}
/* console.log('2 Kazakhsta');
console.log('4 Philippines');
console.log('6 Indonesia');
console.log('7 Malaysia');
console.log('8 Kenya');
console.log('10 Vietnam');
console.log('12 Usa');
console.log('13 Israel');
console.log('22 India');
console.log('31 Southafrica');
console.log('32 Romania');
console.log('40 Uzbekistan '); */
}
async function getPriceGoole(codPais) {
axios.get('https://smshub.org/stubs/handler_api.php?api_key=177294U15a8640801c39bf11bacebea6d324b6b&action=getPrices&service=go&country=' + codPais)
.then(res => {
const headerDate = res.headers && res.headers.date ? res.headers.date : 'no response date';
//console.log('Status Code:', res.status);
//console.log('Date in Response header:', headerDate);
const goObject = res.data[codPais].go;
// Convertendo o objeto 'go' em uma matriz de pares chave-valor
const keyValueArray = Object.entries(goObject);
const primeiraLinha = keyValueArray[0];
if (primeiraLinha[0] < 5) {
if (primeiraLinha != null) {
console.log('Pais:' + codPais + '|' + primeiraLinha);
}
}
})
.catch(err => {
//console.log('Error: ', err.message);
});
}