-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcopy2.js
153 lines (148 loc) ยท 3.15 KB
/
copy2.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const axios = require('axios');
const https = require('https');
const fs = require('fs');
const cheerio = require('cheerio');
const getHtml = async (type) => {
try {
return await axios.get(encodeURI(`https://animalcrossing.fandom.com/wiki/${type}`));
} catch (error) {
console.error(error);
}
};
const get = async (type) => {
const html = await getHtml(type);
let ulList = [];
const $ = cheerio.load(html.data);
const $bodyList = $('tbody').children('tr');
$bodyList.each(function (i, elem) {
ulList[i] = {
title: $(this).find('.image-thumbnail img').attr('src'),
};
const data = ulList.filter((n) => n.title);
return data;
});
// console.log(ulList);
return !!ulList[1] && ulList[1].title;
};
const fetch = async () => {
const arr = [
'Agent K.K.',
'Aloha K.K.',
'Animal City',
'Bubblegum K.K.',
'Cafรฉ K.K.',
'Comrade K.K.',
'DJ K.K.',
"Drivin'",
'Farewell',
'Forest Life',
'Go K.K. Rider',
'Hypno K.K.',
'I Love You',
'Imperial K.K.',
'K.K. Adventure',
'K.K. Aria',
'K.K. Ballad',
'K.K. Bazaar',
'K.K. Birthday',
'K.K. Blues',
'K.K. Bossa',
'K.K. Calypso',
'K.K. Casbah',
'K.K. Chorale',
'K.K. Condor',
'K.K. Country',
"K.K. Cruisin'",
'K.K. D&B',
'K.K. Dirge',
'K.K. Disco',
'K.K. Dixie',
'K.K. รtude',
'K.K. Faire',
'K.K. Flamenco',
'K.K. Folk',
'K.K. Fusion',
'K.K. Groove',
'K.K. Gumbo',
'K.K. House',
'K.K. Island',
'K.K. Jazz',
'K.K. Jongara',
'K.K. Lament',
'K.K. Love Song',
'K.K. Lullaby',
'K.K. Mambo',
'K.K. Marathon',
'K.K. March',
'K.K. Metal',
'K.K. Milonga',
'K.K. Moody',
'K.K. Oasis',
'K.K. Parade',
'K.K. Ragtime',
'K.K. Rally',
'K.K. Reggae',
'K.K. Rock',
'K.K. Rockabilly',
'K.K. Safari',
'K.K. Salsa',
'K.K. Samba',
'K.K. Ska',
'K.K. Sonata',
'K.K. Song',
'K.K. Soul',
'K.K. Steppe',
'K.K. Stroll',
'K.K. Swing',
'K.K. Synth',
'K.K. Tango',
'K.K. Technopop',
'K.K. Waltz',
'K.K. Western',
'King K.K.',
'Lucky K.K.',
'Marine Song 2001',
'Mountain Song',
'Mr. K.K.',
'My Place',
'Neapolitan',
'Only Me',
'Pondering',
"Rockin' K.K.",
'Seรฑor K.K.',
'Soulful K.K.',
'Space K.K.',
'Spring Blossoms',
'Stale Cupcakes',
'Steep Hill',
"Surfin' K.K.",
'The K. Funk',
'To the Edge',
'Two Days Ago',
'Wandering',
'Welcome Horizons',
];
arr.map(async (a) => {
const url = await get(a);
console.log(url);
if (!url) {
console.log(a);
return;
} else {
// // ์ ์ฅํ ์์น๋ฅผ ์ง์
const savepath = './public/musics/images/' + a + '.png';
// ์ถ๋ ฅ ์ง์
const outfile = fs.createWriteStream(savepath);
// ๋น๋๊ธฐ๋ก URL์ ํ์ผ ๋ค์ด๋ก๋
https.get(url, function (res) {
res.pipe(outfile);
res.on('end', function () {
outfile.close();
console.log('ok');
});
});
}
});
// const url = 'https://nooksisland.com' + d.imageUrl;
};
fetch();