This repository has been archived by the owner on Dec 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate-member.js
58 lines (55 loc) · 1.49 KB
/
update-member.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
49
50
51
52
53
54
55
56
57
58
/* eslint-disable */
const fetch = (...args) =>
import("node-fetch")
.then(({ default: f }) => f(...args))
.catch((err) => console.log(err));
const cheerio = require("cheerio");
const { writeFileSync } = require("fs");
const path = require("path");
(async function () {
let page = 1;
let has_next = 1;
let members = [];
do {
let html = await (
await fetch(`https://github.com/orgs/bellshade/people/?page=${page}`)
).text();
let $ = cheerio.load(html);
$(
'[class="d-flex flex-items-center flex-justify-end member-list-item js-bulk-actions-item border border-top-0 "]',
).each(function () {
let avatar = $(this)
.find('[data-hovercard-type="user"]')
.eq(0)
.find("img")
.attr("src");
let name = $(this)
.find('[data-hovercard-type="user"]')
.eq(1)
.text()
.trim();
let uname = $(this)
.find('[data-hovercard-type="user"]')
.eq(1)
.attr("href")
.slice(1);
members.push({
avatar,
name,
username: uname,
});
});
has_next = !$(".next_page").hasClass("disabled") ? 1 : 0;
page++;
} while (has_next === 1);
console.log(`Recieved ${members.length} members data.`);
members.forEach((f) => {
console.log(`Name: ${f.name}
Username: ${f.username}
Avatar URL: ${f.avatar}\n`);
});
writeFileSync(
path.join(__dirname, "data-json", "bellshade-member.json"),
JSON.stringify(members, null, 2),
);
})(0);