stack-analyze 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -24
- package/about.js +7 -3
- package/api/webApis.js +1 -1
- package/cli.js +42 -18
- package/functions/animeInfo.js +6 -1
- package/functions/bitly.js +6 -1
- package/functions/bundlephobia.js +36 -0
- package/functions/cryptoList.js +4 -2
- package/functions/gitUser.js +6 -1
- package/functions/hardware.js +119 -186
- package/functions/moviesInfo.js +6 -1
- package/functions/multipleStack.js +8 -2
- package/functions/pageSpeed.js +12 -0
- package/functions/password.js +4 -0
- package/functions/scraping.js +54 -15
- package/functions/singleStack.js +7 -3
- package/functions/twitch.js +50 -15
- package/hash/infoTools.js +57 -0
- package/hash/queryTools.js +5 -34
- package/hash/utilityTools.js +21 -0
- package/index.cjs +22 -1
- package/index.mjs +22 -1
- package/logo-module.webp +0 -0
- package/package.json +9 -9
- package/readme.md +1 -1
- package/utils.js +41 -3
- package/logo-module.png +0 -0
package/functions/hardware.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// modules
|
|
2
|
+
import { createWriteStream } from "node:fs";
|
|
2
3
|
import {
|
|
3
4
|
cpu,
|
|
4
5
|
mem,
|
|
@@ -8,9 +9,13 @@ import {
|
|
|
8
9
|
bios
|
|
9
10
|
} from "systeminformation";
|
|
10
11
|
import colors from "colors";
|
|
11
|
-
import { printTable } from "console-table-printer";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import { stackSave } from "../utils.js";
|
|
14
|
+
|
|
15
|
+
const hardwareinfo = createWriteStream("hardware.csv");
|
|
16
|
+
|
|
17
|
+
const csvHeader = (obj) => `${Object.keys(obj).join(";")}\n`;
|
|
18
|
+
const csvData = (obj, spaces) => `${Object.values(obj).join(";")}${spaces}`;
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
*
|
|
@@ -18,200 +23,128 @@ const timeout = 1e3;
|
|
|
18
23
|
* @param {number} [base = 1073741824]
|
|
19
24
|
* @returns {string}
|
|
20
25
|
*/
|
|
21
|
-
const gigabyteConvert = (size, base=1073741824) => (size / base).toFixed(2);
|
|
22
|
-
|
|
23
|
-
const hardwareTools = {
|
|
24
|
-
async cpuInfo(refreshCallback) {
|
|
25
|
-
console.clear();
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const {
|
|
29
|
-
manufacturer,
|
|
30
|
-
brand,
|
|
31
|
-
speed,
|
|
32
|
-
cores,
|
|
33
|
-
physicalCores,
|
|
34
|
-
processors,
|
|
35
|
-
vendor,
|
|
36
|
-
family,
|
|
37
|
-
model
|
|
38
|
-
} = await cpu();
|
|
26
|
+
const gigabyteConvert = (size, base = 1073741824) => (size / base).toFixed(2);
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @async
|
|
31
|
+
* @returns {Promise<void>}
|
|
32
|
+
*/
|
|
33
|
+
export default async function hardware() {
|
|
34
|
+
try {
|
|
35
|
+
// bios info
|
|
36
|
+
const biosInfo = await bios();
|
|
37
|
+
|
|
38
|
+
for (const key in biosInfo) {
|
|
39
|
+
if (!biosInfo[key]) {
|
|
40
|
+
delete biosInfo[key];
|
|
41
|
+
}
|
|
54
42
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.clear();
|
|
43
|
+
|
|
44
|
+
hardwareinfo.write(csvHeader(biosInfo));
|
|
45
|
+
hardwareinfo.write(csvData(biosInfo, "\n\n"));
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} = await mem();
|
|
68
|
-
|
|
69
|
-
// show results
|
|
70
|
-
console.table({
|
|
71
|
-
total_mem: `${gigabyteConvert(total)} GB`,
|
|
72
|
-
free_mem: `${gigabyteConvert(free)} GB`,
|
|
73
|
-
used_mem: `${gigabyteConvert(used)} GB`,
|
|
74
|
-
active_mem: `${gigabyteConvert(active)} GB`,
|
|
75
|
-
available_mem: `${gigabyteConvert(available)} GB`
|
|
76
|
-
});
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.error(colors.red(err.message));
|
|
47
|
+
// cpu info
|
|
48
|
+
const cpuInfo = await cpu();
|
|
49
|
+
|
|
50
|
+
for (const key in cpuInfo) {
|
|
51
|
+
if (!cpuInfo[key]) {
|
|
52
|
+
delete cpuInfo[key];
|
|
53
|
+
}
|
|
79
54
|
}
|
|
80
|
-
setTimeout(refreshCallback, timeout);
|
|
81
|
-
},
|
|
82
|
-
async osDetail(refreshCallback) {
|
|
83
|
-
console.clear();
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
distro,
|
|
90
|
-
release,
|
|
91
|
-
kernel,
|
|
92
|
-
arch,
|
|
93
|
-
serial,
|
|
94
|
-
uefi
|
|
95
|
-
} = await osInfo();
|
|
96
|
-
|
|
97
|
-
// show results
|
|
98
|
-
console.table({
|
|
99
|
-
hostname,
|
|
100
|
-
platform,
|
|
101
|
-
distro,
|
|
102
|
-
release,
|
|
103
|
-
kernel,
|
|
104
|
-
arch,
|
|
105
|
-
serial,
|
|
106
|
-
uefi
|
|
107
|
-
});
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.error(colors.red(err.message));
|
|
56
|
+
for (const key in cpuInfo.cache) {
|
|
57
|
+
if (!cpuInfo.cache[key]) {
|
|
58
|
+
delete cpuInfo.cache[key];
|
|
59
|
+
}
|
|
110
60
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
61
|
+
|
|
62
|
+
cpuInfo.cache = Object.entries(cpuInfo.cache)
|
|
63
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
64
|
+
.join(" ");
|
|
65
|
+
|
|
66
|
+
hardwareinfo.write(csvHeader(cpuInfo));
|
|
67
|
+
hardwareinfo.write(csvData(cpuInfo, "\n\n"));
|
|
115
68
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
size,
|
|
124
|
-
interfaceType
|
|
125
|
-
}) => ({
|
|
126
|
-
type,
|
|
127
|
-
name,
|
|
128
|
-
vendor,
|
|
129
|
-
diskSize: `${gigabyteConvert(size)} GB`,
|
|
130
|
-
interfaceType
|
|
131
|
-
}));
|
|
132
|
-
|
|
133
|
-
printTable(disksList);
|
|
134
|
-
|
|
135
|
-
} catch (err) {
|
|
136
|
-
console.error(colors.red(err.message));
|
|
69
|
+
// os info
|
|
70
|
+
const os = await osInfo();
|
|
71
|
+
|
|
72
|
+
for (const key in os) {
|
|
73
|
+
if (!os[key]) {
|
|
74
|
+
delete os[key];
|
|
75
|
+
}
|
|
137
76
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
77
|
+
|
|
78
|
+
hardwareinfo.write(csvHeader(os));
|
|
79
|
+
hardwareinfo.write(csvData(os, "\n\n"));
|
|
80
|
+
|
|
142
81
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
vendor,
|
|
149
|
-
vram
|
|
150
|
-
}) => ({
|
|
151
|
-
model,
|
|
152
|
-
vendor,
|
|
153
|
-
vramSize: vram < 1024
|
|
154
|
-
? `${vram} MB`
|
|
155
|
-
: `${gigabyteConvert(vram, 1024)} GB`
|
|
156
|
-
}));
|
|
157
|
-
|
|
158
|
-
// show results
|
|
159
|
-
printTable(controllersList);
|
|
160
|
-
} catch (err) {
|
|
161
|
-
console.error(colors.red(err.message));
|
|
82
|
+
// ram memory info
|
|
83
|
+
const ram = await mem();
|
|
84
|
+
|
|
85
|
+
for (const key in ram) {
|
|
86
|
+
ram[key] = `${gigabyteConvert(ram[key])} GB`;
|
|
162
87
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
console.clear();
|
|
88
|
+
|
|
89
|
+
hardwareinfo.write(csvHeader(ram));
|
|
90
|
+
hardwareinfo.write(csvData(ram));
|
|
167
91
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
resolutionY
|
|
177
|
-
}) => ({
|
|
178
|
-
model,
|
|
179
|
-
main,
|
|
180
|
-
connection,
|
|
181
|
-
resolutionX,
|
|
182
|
-
resolutionY
|
|
183
|
-
}));
|
|
184
|
-
|
|
185
|
-
// show results
|
|
186
|
-
printTable(displayList);
|
|
187
|
-
} catch (err) {
|
|
188
|
-
console.error(colors.red(err.message));
|
|
189
|
-
}
|
|
190
|
-
setTimeout(refreshCallback, timeout);
|
|
191
|
-
},
|
|
192
|
-
async biosInfo(refreshCallback) {
|
|
193
|
-
console.clear();
|
|
92
|
+
// disks
|
|
93
|
+
const disks = await diskLayout();
|
|
94
|
+
|
|
95
|
+
disks.forEach(disk => {
|
|
96
|
+
for (const key in disk) {
|
|
97
|
+
if (!disk[key]) {
|
|
98
|
+
delete disk[key];
|
|
99
|
+
}
|
|
194
100
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
releaseDate,
|
|
205
|
-
vendor,
|
|
206
|
-
bios_revision: revision || "no info",
|
|
207
|
-
version
|
|
208
|
-
});
|
|
209
|
-
} catch (err) {
|
|
210
|
-
console.error(colors.red(err.message));
|
|
211
|
-
}
|
|
212
|
-
setTimeout(refreshCallback, timeout);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
101
|
+
if (typeof disk[key] === "number") {
|
|
102
|
+
disk[key] = `${gigabyteConvert(ram[key])} GB`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
hardwareinfo.write(csvHeader(disk));
|
|
107
|
+
hardwareinfo.write(csvData(disk, "\n"));
|
|
108
|
+
});
|
|
109
|
+
hardwareinfo.write("\n");
|
|
215
110
|
|
|
216
|
-
|
|
217
|
-
|
|
111
|
+
/* displays & controllers */
|
|
112
|
+
const { displays, controllers } = await graphics();
|
|
113
|
+
|
|
114
|
+
// controllers
|
|
115
|
+
controllers.forEach(controller => {
|
|
116
|
+
for (const key in controller) {
|
|
117
|
+
if (!controller[key]) {
|
|
118
|
+
delete controller[key];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (typeof controller[key] === "number") {
|
|
122
|
+
controller[key] = controller[key] < 1024
|
|
123
|
+
? `${controller[key]} MB`
|
|
124
|
+
: `${gigabyteConvert(controller[key])} GB`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
hardwareinfo.write(csvHeader(controller));
|
|
129
|
+
hardwareinfo.write(csvData(controller, "\n"));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
hardwareinfo.write("\n");
|
|
133
|
+
|
|
134
|
+
displays.forEach(display => {
|
|
135
|
+
for (const key in display) {
|
|
136
|
+
if (!display[key]) {
|
|
137
|
+
delete display[key];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
hardwareinfo.write(csvHeader(display));
|
|
142
|
+
hardwareinfo.write(csvData(display, "\n"));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// finish
|
|
146
|
+
console.info("finish the hardware information file");
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.error(colors.red(err.message));
|
|
149
|
+
}
|
|
150
|
+
}
|
package/functions/moviesInfo.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// modules
|
|
2
|
-
import
|
|
2
|
+
import axios from "axios";
|
|
3
3
|
import colors from "colors";
|
|
4
4
|
import { printTable } from "console-table-printer";
|
|
5
5
|
|
|
6
|
+
// save movies
|
|
7
|
+
import { stackSave } from "../utils.js";
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* @description movie info tool
|
|
8
11
|
* @async
|
|
@@ -44,6 +47,8 @@ export default async function movieDB(query, token) {
|
|
|
44
47
|
.filter((data) => data?.release_date);
|
|
45
48
|
|
|
46
49
|
printTable(movieData);
|
|
50
|
+
|
|
51
|
+
stackSave("movie-list.json", JSON.stringify(movieData, null, 2));
|
|
47
52
|
} catch (err) {
|
|
48
53
|
console.error(colors.red(err.message));
|
|
49
54
|
}
|
|
@@ -4,7 +4,7 @@ import { printTable } from "console-table-printer";
|
|
|
4
4
|
import { wappalyzer } from "../api/webApis.js";
|
|
5
5
|
|
|
6
6
|
// list format
|
|
7
|
-
import { listFormat } from "../utils.js";
|
|
7
|
+
import { listFormat, stackSave } from "../utils.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -19,6 +19,8 @@ export default async function multipleStack(urlList) {
|
|
|
19
19
|
|
|
20
20
|
console.info("multiple websites tech stack \n");
|
|
21
21
|
|
|
22
|
+
const stacks = {};
|
|
23
|
+
|
|
22
24
|
for await (const url of urlList) {
|
|
23
25
|
console.info(url.green);
|
|
24
26
|
|
|
@@ -37,8 +39,12 @@ export default async function multipleStack(urlList) {
|
|
|
37
39
|
};
|
|
38
40
|
});
|
|
39
41
|
|
|
40
|
-
printTable(stackResult);
|
|
42
|
+
printTable(stackResult.slice(0, 10));
|
|
43
|
+
|
|
44
|
+
stacks[url] = stackResult;
|
|
41
45
|
}
|
|
46
|
+
|
|
47
|
+
stackSave("multiple-stack.json", JSON.stringify(stacks, null, 2));
|
|
42
48
|
} catch (err) {
|
|
43
49
|
console.error(colors.red(err.message));
|
|
44
50
|
}
|
package/functions/pageSpeed.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// modules
|
|
2
2
|
import { MultiBar, Presets } from "cli-progress";
|
|
3
|
+
import figlet from "figlet";
|
|
3
4
|
import colors from "colors";
|
|
4
5
|
|
|
6
|
+
// save file
|
|
7
|
+
import { stackSave } from "../utils.js";
|
|
8
|
+
|
|
5
9
|
// pagespeed api
|
|
6
10
|
import { pagespeedApi } from "../api/webApis.js";
|
|
7
11
|
|
|
@@ -66,6 +70,14 @@ export default async function pagespeed(url) {
|
|
|
66
70
|
|
|
67
71
|
// stop multibar
|
|
68
72
|
multibar.stop();
|
|
73
|
+
|
|
74
|
+
const resultTxt = `
|
|
75
|
+
${figlet.textSync(url)} \n
|
|
76
|
+
mobile: ${mobile}/100 \n
|
|
77
|
+
desktop: ${desktop}/100
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
stackSave("pagespeed.txt", resultTxt);
|
|
69
81
|
} catch (err) {
|
|
70
82
|
console.error(colors.red(err.message));
|
|
71
83
|
}
|
package/functions/password.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// save password
|
|
2
|
+
import { stackSave } from "../utils.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* It generates a random password
|
|
3
6
|
* @returns {void}
|
|
@@ -17,4 +20,5 @@ export default function genPassword() {
|
|
|
17
20
|
|
|
18
21
|
// print new passwors
|
|
19
22
|
console.info("new password:", password);
|
|
23
|
+
stackSave("password.txt", `new password: ${password}`)
|
|
20
24
|
}
|
package/functions/scraping.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import axios from "axios";
|
|
2
2
|
import { load } from "cheerio";
|
|
3
3
|
import colors from "colors";
|
|
4
4
|
import { printTable } from "console-table-printer";
|
|
5
5
|
|
|
6
|
+
// stack save
|
|
7
|
+
import { stackSave } from "../utils.js";
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* @typedef {"title"|"images"|"metadata"|"headings"|"table_heading"|"table_data"|"links"|"cites"} Options
|
|
8
11
|
*
|
|
@@ -15,18 +18,27 @@ export default async function scrape(url, options) {
|
|
|
15
18
|
try {
|
|
16
19
|
const { data } = await axios.get(url);
|
|
17
20
|
const $ = load(data);
|
|
21
|
+
|
|
22
|
+
let result;
|
|
18
23
|
|
|
19
24
|
const scraping = {
|
|
20
|
-
title
|
|
25
|
+
title() {
|
|
26
|
+
result = `url title: ${$("title").text()}`;
|
|
27
|
+
console.info($("title").text());
|
|
28
|
+
},
|
|
21
29
|
images() {
|
|
22
30
|
const imageList = $("img").map((i, el) => ({
|
|
23
31
|
imagePath: $(el).attr("src"),
|
|
24
32
|
imageTitle: $(el).attr("alt")
|
|
25
33
|
})).toArray();
|
|
34
|
+
|
|
35
|
+
result = imageList.length === 0
|
|
36
|
+
? "no found images"
|
|
37
|
+
: imageList;
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
? console.info(
|
|
29
|
-
: printTable(
|
|
39
|
+
typeof result === "string"
|
|
40
|
+
? console.info(result)
|
|
41
|
+
: printTable(result);
|
|
30
42
|
},
|
|
31
43
|
metadata() {
|
|
32
44
|
const metadataList = $("meta").map((i, el) => ({
|
|
@@ -34,6 +46,8 @@ export default async function scrape(url, options) {
|
|
|
34
46
|
metaContent: $(el).attr("content")
|
|
35
47
|
})).toArray()
|
|
36
48
|
.filter((data) => data?.metaInfo);
|
|
49
|
+
|
|
50
|
+
result = metadataList;
|
|
37
51
|
|
|
38
52
|
printTable(metadataList);
|
|
39
53
|
},
|
|
@@ -42,28 +56,43 @@ export default async function scrape(url, options) {
|
|
|
42
56
|
headingTag: $(el).prop("tagName"),
|
|
43
57
|
headingText: $(el).text()
|
|
44
58
|
})).toArray();
|
|
59
|
+
|
|
60
|
+
result = headingList.length === 0
|
|
61
|
+
? "no found heading tags"
|
|
62
|
+
: headingList;
|
|
45
63
|
|
|
46
|
-
|
|
64
|
+
typeof result === "string"
|
|
65
|
+
? console.info("no found heading tags")
|
|
66
|
+
:printTable(headingList);
|
|
47
67
|
},
|
|
48
68
|
tableHead() {
|
|
49
69
|
const tableHeadList = $("th").map((i, el) => ({
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
thCol: $(el).index(),
|
|
71
|
+
thData: $(el).text()
|
|
52
72
|
})).toArray();
|
|
73
|
+
|
|
74
|
+
result = tableHeadList.length === 0
|
|
75
|
+
? "no found th tags"
|
|
76
|
+
: tableHeadList;
|
|
53
77
|
|
|
54
|
-
|
|
78
|
+
typeof result === "string"
|
|
55
79
|
? console.info("no found th tags")
|
|
56
80
|
: printTable(tableHeadList);
|
|
57
81
|
},
|
|
58
82
|
tableData() {
|
|
59
83
|
const tableColumnList = $("td").map((i, el) => ({
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
rowID: $(el).parent().index(),
|
|
85
|
+
colID: $(el).index(),
|
|
86
|
+
colData: $(el).text(),
|
|
62
87
|
})).toArray();
|
|
88
|
+
|
|
89
|
+
result = tableColumnList.length === 0
|
|
90
|
+
? "no found td tags"
|
|
91
|
+
: tableColumnList;
|
|
63
92
|
|
|
64
|
-
|
|
65
|
-
? console.info(
|
|
66
|
-
: console.table(
|
|
93
|
+
typeof result === "string"
|
|
94
|
+
? console.info(result)
|
|
95
|
+
: console.table(result.slice(0, 10));
|
|
67
96
|
},
|
|
68
97
|
links() {
|
|
69
98
|
const linkList = $("a").map((i, el) => ({
|
|
@@ -72,6 +101,8 @@ export default async function scrape(url, options) {
|
|
|
72
101
|
})).toArray()
|
|
73
102
|
.filter(({ url }) => url.indexOf("#") !== 0);
|
|
74
103
|
|
|
104
|
+
result = linkList
|
|
105
|
+
|
|
75
106
|
printTable(linkList);
|
|
76
107
|
},
|
|
77
108
|
cites() {
|
|
@@ -80,14 +111,22 @@ export default async function scrape(url, options) {
|
|
|
80
111
|
citeLink: $(el).attr("cite"),
|
|
81
112
|
citeText: $(el).text()
|
|
82
113
|
})).toArray();
|
|
114
|
+
|
|
115
|
+
result = citeList.length === 0
|
|
116
|
+
? "no found q and/or blockquote tags"
|
|
117
|
+
: citeList;
|
|
83
118
|
|
|
84
|
-
|
|
119
|
+
typeof result === "string"
|
|
85
120
|
? console.info("no found q and/or blockquote tags")
|
|
86
121
|
: printTable(citeList);
|
|
87
122
|
}
|
|
88
123
|
};
|
|
89
124
|
|
|
90
125
|
scraping[options]();
|
|
126
|
+
|
|
127
|
+
typeof result === "string"
|
|
128
|
+
? stackSave('scraping.txt', result)
|
|
129
|
+
: stackSave('scraping.json', JSON.stringify(result, null, 2));
|
|
91
130
|
} catch (err) {
|
|
92
131
|
console.error(colors.red(err.message));
|
|
93
132
|
}
|
package/functions/singleStack.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import colors from "colors";
|
|
3
3
|
import { printTable } from "console-table-printer";
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
import { listFormat } from "../utils.js";
|
|
5
|
+
// utils
|
|
6
|
+
import { listFormat, stackSave } from "../utils.js";
|
|
7
|
+
|
|
8
|
+
// wappalyzer
|
|
7
9
|
import { wappalyzer } from "../api/webApis.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -35,7 +37,9 @@ export default async function singleStack(url) {
|
|
|
35
37
|
|
|
36
38
|
console.info(url.green);
|
|
37
39
|
|
|
38
|
-
printTable(stackResult);
|
|
40
|
+
printTable(stackResult.slice(0, 10));
|
|
41
|
+
|
|
42
|
+
stackSave("single-stack.json", JSON.stringify(stackResult, null, 2));
|
|
39
43
|
} catch (err) {
|
|
40
44
|
console.error(colors.red(err.message));
|
|
41
45
|
}
|
package/functions/twitch.js
CHANGED
|
@@ -1,36 +1,71 @@
|
|
|
1
1
|
// modules
|
|
2
|
-
import
|
|
2
|
+
import axios from "axios";
|
|
3
3
|
import { format } from "timeago.js";
|
|
4
|
+
import { printTable } from "console-table-printer";
|
|
4
5
|
import colors from "colors";
|
|
5
6
|
|
|
7
|
+
// save twitch users
|
|
8
|
+
import { stackSave } from "../utils.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* types for twitch info
|
|
12
|
+
*
|
|
13
|
+
* @typedef {Object} Twitch
|
|
14
|
+
* @property {string} Twitch.twitchUsers
|
|
15
|
+
* @property {string} Twitch.twitchSeparator
|
|
16
|
+
* @property {string} Twitch.twitchToken
|
|
17
|
+
* @property {string} Twitch.twitchClient
|
|
18
|
+
*/
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
|
-
*
|
|
8
21
|
* @description twitch user info
|
|
9
22
|
* @async
|
|
10
|
-
* @param {
|
|
11
|
-
* @param { string } twitchClient - twitch client code
|
|
12
|
-
* @param { string } apiToken - twitch api token
|
|
23
|
+
* @param {Twitch} param
|
|
13
24
|
* @returns { Promise<void> } - return twitch results
|
|
14
25
|
*/
|
|
15
|
-
export default async function twitchInfo(
|
|
26
|
+
export default async function twitchInfo({
|
|
27
|
+
twitchUsers,
|
|
28
|
+
twitchSeparator,
|
|
29
|
+
twitchToken,
|
|
30
|
+
twitchClient
|
|
31
|
+
}) {
|
|
32
|
+
|
|
33
|
+
const userList = twitchUsers.split(twitchSeparator);
|
|
34
|
+
|
|
35
|
+
if(userList.length === 10) {
|
|
36
|
+
console.error("twitch users must be 10".bgRed);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const params = new URLSearchParams();
|
|
40
|
+
|
|
41
|
+
userList.forEach((item) => {
|
|
42
|
+
params.append("login", item);
|
|
43
|
+
});
|
|
16
44
|
|
|
17
45
|
try {
|
|
18
46
|
const { data: twitchData } = await axios.get("https://api.twitch.tv/helix/users", {
|
|
19
|
-
params
|
|
47
|
+
params,
|
|
20
48
|
headers: {
|
|
21
|
-
Authorization: `Bearer ${
|
|
49
|
+
Authorization: `Bearer ${twitchToken}`,
|
|
22
50
|
"Client-Id": twitchClient
|
|
23
51
|
}
|
|
24
52
|
});
|
|
25
53
|
|
|
26
|
-
const result = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
54
|
+
const result = twitchData.data.map(({
|
|
55
|
+
display_name,
|
|
56
|
+
broadcaster_type,
|
|
57
|
+
view_count,
|
|
58
|
+
created_at
|
|
59
|
+
}) => ({
|
|
60
|
+
username: display_name,
|
|
61
|
+
broadcaster: broadcaster_type || "user",
|
|
62
|
+
viewCount: view_count,
|
|
63
|
+
accountDate: new Date(created_at).toLocaleDateString(),
|
|
64
|
+
accountAge: format(created_at)
|
|
65
|
+
}));
|
|
32
66
|
|
|
33
|
-
|
|
67
|
+
printTable(result);
|
|
68
|
+
stackSave("twitch-users.json", JSON.stringify(result, null, 2));
|
|
34
69
|
} catch (err) {
|
|
35
70
|
console.error(colors.red(err));
|
|
36
71
|
}
|