-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 1.05 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
const axios = require("axios");
const { parse } = require("node-html-parser");
const fs = require("fs");
let numberErrors = 0;
let numberSuccess = 0;
const root_damins = fs.readFileSync("root-damins.txt", "utf8").split("\n");
const runApp = async () => {
numberErrors = 0;
numberSuccess = 0;
fs.writeFileSync("mobileNumbers.txt", "");
fs.writeFileSync("errors.txt", "");
for (const root_damin of root_damins) {
try {
const response = await axios.get(`https://${root_damin}`);
const parsedResponse = parse(response.data);
const mobileRegex = /(\+98|0)?9\d{9}/g;
const mobileNumbers = parsedResponse.toString().match(mobileRegex);
if (mobileNumbers && mobileNumbers.length > 0) {
fs.appendFileSync("mobileNumbers.txt", mobileNumbers.join("\n") + "\n");
numberSuccess++;
}
} catch (err) {
numberErrors++;
fs.appendFileSync("errors.txt", `${root_damin}\n`);
}
}
console.log(`Number of errors: ${numberErrors}`);
console.log(`Number of success: ${numberSuccess}`);
};
runApp();