stack-analyze 1.2.0 → 1.2.2
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 +18 -0
- package/about.js +19 -11
- package/api/webApis.js +25 -0
- package/cli.js +141 -382
- package/functions/animeInfo.js +13 -14
- package/functions/bitly.js +16 -16
- package/functions/cryptoList.js +9 -15
- package/functions/gitUser.js +18 -18
- package/functions/hardware.js +96 -177
- package/functions/moviesInfo.js +10 -6
- package/functions/multipleStack.js +19 -28
- package/functions/pageSpeed.js +64 -96
- package/functions/password.js +10 -11
- package/functions/scraping.js +123 -143
- package/functions/singleStack.js +10 -9
- package/functions/twitch.js +43 -15
- package/hash/infoTools.js +46 -0
- package/hash/queryTools.js +52 -0
- package/hash/utilityTools.js +21 -0
- package/hash/webTools.js +58 -0
- package/index.cjs +117 -163
- package/index.mjs +120 -168
- package/package.json +9 -9
- package/scraping.json +6 -0
- package/utils.js +78 -4
- package/validations/infoValidations.js +37 -0
- package/validations/webValidations.js +33 -0
package/index.cjs
CHANGED
|
@@ -11,15 +11,24 @@ const {
|
|
|
11
11
|
const Wappalyzer = require("wappalyzer");
|
|
12
12
|
const cheerio = require("cheerio");
|
|
13
13
|
|
|
14
|
+
const gigabyteConvert = (size, base=1073741824) => (size / base).toFixed(2);
|
|
15
|
+
|
|
16
|
+
const wappalyzer = new Wappalyzer();
|
|
17
|
+
|
|
18
|
+
const pagespeedApi = async (url, strategy) => await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
|
|
19
|
+
params: {
|
|
20
|
+
url,
|
|
21
|
+
key: "AIzaSyBEDaW4FxSZ2s1vz5CdD5Ai6PGZGdAzij0",
|
|
22
|
+
strategy
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
14
26
|
const animeSearch = async ({ query, results, failed }) => {
|
|
15
27
|
/* error manager */
|
|
16
28
|
try {
|
|
17
29
|
// call api
|
|
18
30
|
const { data } = await axios.get("https://api.jikan.moe/v/anime", {
|
|
19
|
-
params: {
|
|
20
|
-
q: query,
|
|
21
|
-
limit: 10
|
|
22
|
-
}
|
|
31
|
+
params: { q: query }
|
|
23
32
|
});
|
|
24
33
|
|
|
25
34
|
results(data.results);
|
|
@@ -31,9 +40,7 @@ const bitlyInfo = async ({ link, token, results, failed }) => {
|
|
|
31
40
|
try {
|
|
32
41
|
const { data } = await axios.post(
|
|
33
42
|
"https://api-ssl.bitly.com/v4/expand",
|
|
34
|
-
{
|
|
35
|
-
bitlink_id: link
|
|
36
|
-
},
|
|
43
|
+
{ bitlink_id: link },
|
|
37
44
|
{
|
|
38
45
|
headers: {
|
|
39
46
|
Authorization: `Bearer ${token}`,
|
|
@@ -112,11 +119,11 @@ async function ramMemInfo(callback) {
|
|
|
112
119
|
|
|
113
120
|
// show results
|
|
114
121
|
callback({
|
|
115
|
-
total_mem: `${(total
|
|
116
|
-
free_mem: `${(free
|
|
117
|
-
used_mem: `${(used
|
|
118
|
-
active_mem: `${(active
|
|
119
|
-
available_mem: `${(available
|
|
122
|
+
total_mem: `${gigabyteConvert(total)} GB`,
|
|
123
|
+
free_mem: `${gigabyteConvert(free)} GB`,
|
|
124
|
+
used_mem: `${gigabyteConvert(used)} GB`,
|
|
125
|
+
active_mem: `${gigabyteConvert(active)} GB`,
|
|
126
|
+
available_mem: `${gigabyteConvert(available)} GB`
|
|
120
127
|
});
|
|
121
128
|
} catch (err) { callback(err); }
|
|
122
129
|
}
|
|
@@ -162,7 +169,7 @@ async function diskInfo(callback) {
|
|
|
162
169
|
type,
|
|
163
170
|
name,
|
|
164
171
|
vendor,
|
|
165
|
-
diskSize: `${(size
|
|
172
|
+
diskSize: `${gigabyteConvert(size)} GB`,
|
|
166
173
|
interfaceType
|
|
167
174
|
}));
|
|
168
175
|
|
|
@@ -184,7 +191,7 @@ async function controllerInfo(callback) {
|
|
|
184
191
|
vendor,
|
|
185
192
|
vramSize: vram < 1024
|
|
186
193
|
? `${vram} MB`
|
|
187
|
-
: `${(vram
|
|
194
|
+
: `${gigabyteConvert(vram, 1024)} GB`
|
|
188
195
|
}));
|
|
189
196
|
|
|
190
197
|
callback(controllersList);
|
|
@@ -229,11 +236,7 @@ async function biosInfo(callback) {
|
|
|
229
236
|
const movieDB = async ({ api_key, query, results, failed }) => {
|
|
230
237
|
try {
|
|
231
238
|
const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
|
|
232
|
-
params: {
|
|
233
|
-
api_key,
|
|
234
|
-
query,
|
|
235
|
-
page: 1
|
|
236
|
-
}
|
|
239
|
+
params: { api_key, query }
|
|
237
240
|
});
|
|
238
241
|
|
|
239
242
|
const movieData = data.results
|
|
@@ -257,7 +260,7 @@ const movieDB = async ({ api_key, query, results, failed }) => {
|
|
|
257
260
|
|
|
258
261
|
return primaryDate.getTime() - secondaryDate.getTime();
|
|
259
262
|
})
|
|
260
|
-
.filter((
|
|
263
|
+
.filter((data) => data?.release_date);
|
|
261
264
|
|
|
262
265
|
results(movieData);
|
|
263
266
|
} catch (err) { failed(err); }
|
|
@@ -265,7 +268,6 @@ const movieDB = async ({ api_key, query, results, failed }) => {
|
|
|
265
268
|
|
|
266
269
|
async function multipleStack({ urls, results, failed }) {
|
|
267
270
|
let result;
|
|
268
|
-
const wappalyzer = new Wappalyzer();
|
|
269
271
|
try {
|
|
270
272
|
await wappalyzer.init();
|
|
271
273
|
result = await Promise.all(
|
|
@@ -284,21 +286,9 @@ async function multipleStack({ urls, results, failed }) {
|
|
|
284
286
|
|
|
285
287
|
const pageSpeed = async ({ url, results, failed }) => {
|
|
286
288
|
try {
|
|
287
|
-
const resMobile = await
|
|
288
|
-
params: {
|
|
289
|
-
url,
|
|
290
|
-
key: "AIzaSyBEDaW4FxSZ2s1vz5CdD5Ai6PGZGdAzij0",
|
|
291
|
-
strategy: "mobile"
|
|
292
|
-
}
|
|
293
|
-
});
|
|
289
|
+
const resMobile = await pagespeedApi(url, "mobile");
|
|
294
290
|
|
|
295
|
-
const resDesktop = await
|
|
296
|
-
params: {
|
|
297
|
-
url,
|
|
298
|
-
key: "AIzaSyBEDaW4FxSZ2s1vz5CdD5Ai6PGZGdAzij0",
|
|
299
|
-
strategy: "desktop"
|
|
300
|
-
}
|
|
301
|
-
});
|
|
291
|
+
const resDesktop = await pagespeedApi(url, "desktop");
|
|
302
292
|
|
|
303
293
|
// extract results
|
|
304
294
|
const mobile = Math.round(resMobile.data.lighthouseResult.categories.performance.score * 100);
|
|
@@ -309,9 +299,8 @@ const pageSpeed = async ({ url, results, failed }) => {
|
|
|
309
299
|
};
|
|
310
300
|
|
|
311
301
|
async function singleStack({ url, results, failed }) {
|
|
312
|
-
const wappalyzer = await new Wappalyzer;
|
|
313
|
-
|
|
314
302
|
let result;
|
|
303
|
+
|
|
315
304
|
try {
|
|
316
305
|
await wappalyzer.init();
|
|
317
306
|
|
|
@@ -334,8 +323,9 @@ async function singleStack({ url, results, failed }) {
|
|
|
334
323
|
|
|
335
324
|
async function twitchInfo({ query, token, clientID, results, failed }) {
|
|
336
325
|
try {
|
|
337
|
-
const { data: twitchData } = await axios.get(
|
|
326
|
+
const { data: twitchData } = await axios.get("https://api.twitch.tv/helix/users",
|
|
338
327
|
{
|
|
328
|
+
params: { login: query },
|
|
339
329
|
headers: {
|
|
340
330
|
Authorization: `Bearer ${token}`,
|
|
341
331
|
"Client-Id": clientID
|
|
@@ -346,131 +336,95 @@ async function twitchInfo({ query, token, clientID, results, failed }) {
|
|
|
346
336
|
} catch (err) { failed(err); }
|
|
347
337
|
}
|
|
348
338
|
|
|
349
|
-
function scrape(url) {
|
|
350
|
-
let
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const linkList = $("a").map((i, el) => ({
|
|
440
|
-
url: $(el).attr("href"),
|
|
441
|
-
text: $(el).text()
|
|
442
|
-
})).toArray()
|
|
443
|
-
.filter(({ url }) => url.indexOf("#") !== 0);
|
|
444
|
-
|
|
445
|
-
results(linkList);
|
|
446
|
-
} catch (err) { failed(err); }
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
const cites = async ({results, failed}) => {
|
|
450
|
-
try {
|
|
451
|
-
const { data } = await scraping.get(url);
|
|
452
|
-
$ = cheerio.load(data);
|
|
453
|
-
|
|
454
|
-
const citeList = $("q, blockquote").map((i, el) => ({
|
|
455
|
-
citeTag: $(el).prop("tagName"),
|
|
456
|
-
citeLink: $(el).attr("cite"),
|
|
457
|
-
citeText: $(el).text()
|
|
458
|
-
})).toArray();
|
|
459
|
-
|
|
460
|
-
results(citeList);
|
|
461
|
-
} catch (err) { failed(err); }
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
return {
|
|
465
|
-
title,
|
|
466
|
-
images,
|
|
467
|
-
metadata,
|
|
468
|
-
headings,
|
|
469
|
-
table_heading,
|
|
470
|
-
table_data,
|
|
471
|
-
links,
|
|
472
|
-
cites
|
|
473
|
-
};
|
|
339
|
+
async function scrape({url, options, results, failed}) {
|
|
340
|
+
let scrapingResult;
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
const { data } = await axios.get(url);
|
|
344
|
+
const $ = cheerio.load(data);
|
|
345
|
+
|
|
346
|
+
const scraping = {
|
|
347
|
+
title() {
|
|
348
|
+
results($("title").text());
|
|
349
|
+
},
|
|
350
|
+
images() {
|
|
351
|
+
const imageList = $("img").map((i, el) => ({
|
|
352
|
+
imagePath: $(el).attr("src"),
|
|
353
|
+
imageTitle: $(el).attr("alt")
|
|
354
|
+
})).toArray();
|
|
355
|
+
|
|
356
|
+
scrapingResult = imageList.length === 0
|
|
357
|
+
? "no found images"
|
|
358
|
+
: imageList;
|
|
359
|
+
|
|
360
|
+
results(scrapingResult);
|
|
361
|
+
},
|
|
362
|
+
metadata() {
|
|
363
|
+
const metadataList = $("meta").map((i, el) => ({
|
|
364
|
+
metaInfo: $(el).attr("name"),
|
|
365
|
+
metaContent: $(el).attr("content")
|
|
366
|
+
})).toArray()
|
|
367
|
+
.filter((data) => data?.metaInfo);
|
|
368
|
+
|
|
369
|
+
results(metadataList);
|
|
370
|
+
},
|
|
371
|
+
headings() {
|
|
372
|
+
const headingList = $("h1, h2, h3, h4, h5, h6").map((i, el) => ({
|
|
373
|
+
headingTag: $(el).prop("tagName"),
|
|
374
|
+
headingText: $(el).text()
|
|
375
|
+
})).toArray();
|
|
376
|
+
|
|
377
|
+
results(headingList);
|
|
378
|
+
},
|
|
379
|
+
tableHead() {
|
|
380
|
+
const tableHeadList = $("th").map((i, el) => ({
|
|
381
|
+
headingRow: i,
|
|
382
|
+
text: $(el).text()
|
|
383
|
+
})).toArray();
|
|
384
|
+
|
|
385
|
+
scrapingResult = tableHeadList.length === 0
|
|
386
|
+
? "no found th tags" : tableHeadList;
|
|
387
|
+
|
|
388
|
+
results(scrapingResult);
|
|
389
|
+
},
|
|
390
|
+
tableData() {
|
|
391
|
+
const tableColumnList = $("td").map((i, el) => ({
|
|
392
|
+
tableRow: i + 1,
|
|
393
|
+
tableData: $(el).text(),
|
|
394
|
+
})).toArray();
|
|
395
|
+
|
|
396
|
+
scrapingResult = tableColumnList.length === 0
|
|
397
|
+
? "no found td tags" : tableColumnList;
|
|
398
|
+
|
|
399
|
+
results(scrapingResult);
|
|
400
|
+
},
|
|
401
|
+
links() {
|
|
402
|
+
const linkList = $("a").map((i, el) => ({
|
|
403
|
+
url: $(el).attr("href"),
|
|
404
|
+
text: $(el).text()
|
|
405
|
+
})).toArray()
|
|
406
|
+
.filter(({ url }) => url.indexOf("#") !== 0);
|
|
407
|
+
|
|
408
|
+
results(linkList);
|
|
409
|
+
},
|
|
410
|
+
cites() {
|
|
411
|
+
const citeList = $("q, blockquote").map((i, el) => ({
|
|
412
|
+
citeTag: $(el).prop("tagName"),
|
|
413
|
+
citeLink: $(el).attr("cite"),
|
|
414
|
+
citeText: $(el).text()
|
|
415
|
+
})).toArray();
|
|
416
|
+
|
|
417
|
+
scrapingResult = citeList.length === 0
|
|
418
|
+
? "no found q and/or blockquote tags" : citeList;
|
|
419
|
+
|
|
420
|
+
results(scrapingResult);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
scraping[options]();
|
|
425
|
+
} catch (err) {
|
|
426
|
+
failed(err.message);
|
|
427
|
+
}
|
|
474
428
|
}
|
|
475
429
|
|
|
476
430
|
const password = () => {
|