-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.js
46 lines (43 loc) · 1.17 KB
/
data.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
let Xray = require("x-ray");
const axios = require("axios");
let x = Xray();
module.exports = {
codechef: async (userId) => {
let obj = await x(
"https://www.codechef.com/users/" + userId,
".rating-header",
[{ rating: "small@text" }]
);
let rating = obj[0].rating;
rating = rating.split(" ");
// console.log(rating[2].split(")")[0]);
rating = rating[2].split(")")[0];
// console.log(t);
return rating;
},
codeforces: async (userId) => {
let obj = await axios.get(
"https://codeforces.com/api/user.info?handles=" + userId
);
let rating = obj.data.result[0].maxRating;
return rating;
},
atcoder: async (userId) => {
let obj = await x("https://atcoder.jp/users/" + userId, ".dl-table", [
{ rating: "" },
]);
let rating = obj[1].rating;
rating = rating.replace(/\s/g, " ");
rating = rating.split(" ");
let newArray = [];
rating = rating.forEach((element) => {
if (element != "") newArray.push(element);
});
for (let i = 0; i < newArray.length; i++)
if (newArray[i] == "―") {
rating = newArray[i - 1];
break;
}
return rating;
},
};