-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathscraper.js
More file actions
30 lines (24 loc) · 702 Bytes
/
scraper.js
File metadata and controls
30 lines (24 loc) · 702 Bytes
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
const axios = require("axios");
const cheerio = require("cheerio");
const config = require("./config");
module.exports.fetchViewsCountAndFollowers = async () => {
const { dashboardUrl, cookieHeader } = config;
const response = await axios.get(dashboardUrl, {
headers: {
cookie: cookieHeader
}
});
const $ = cheerio.load(response.data);
const viewsCount = $(
"#main-content > header > div.grid.grid-cols-2.gap-2.pt-3 > div:nth-child(3) > strong"
).text();
const followersCount = parseInt(
$(
"#main-content > div.crayons-layout__sidebar-left > nav > ul > li:nth-child(3) > a > span"
).text()
);
return {
viewsCount,
followersCount
};
};