-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.js
38 lines (34 loc) · 808 Bytes
/
count.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
const fs = require('fs')
const axios = require('axios')
const oisa = []
const getPage = async nameUser => {
try {
const {
status
} = await axios.get(`https://instagram.com/${nameUser}`);
if (status === 200) {
return nameUser
}
} catch (error) {
console.error(error);
}
}
const jsonData = fs.readFileSync("./user.json", "utf8");
// (async () => {
// JSON.parse(jsonData).forEach(async element => {
// await getPage(element)
// });
// })()
let coisa
(async () => {
coisa = JSON.parse(jsonData).map(a => getPage(a).then(res => {
oisa.push(res)
fs.appendFile(`user.json`, JSON.stringify(oisa), err => {
if (err) throw err;
console.log('Ok!');
});
}))
// coisa.then(res => {
// console.log(res)})
// console.log(coisa)
})()