scraperjavascript113
MyAnimeList Scraper (Search, Detail Anime & Top Rankings)
Scraper MyAnimeList.net untuk mencari anime lengkap dengan sinopsis, poster HD, metadata detail (studio, produser, genre, skor, episode), serta daftar Top Anime ranking.
Vamz Spectre18 Nov 2026296 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/myanimelist" -o myanimelist.js
# 2. Jalankan script
node myanimelist.js
Dependencies npm yang Dibutuhkan:
npm install axios cheerioPanduan Penggunaan:
// Download Script: curl -sL "https://code.vamxapi.my.id/snippet/raw/myanimelist" -o myanimelist.js // 1. Cari Anime: node myanimelist.js "naruto" // 2. Detail Anime (ID atau URL): node myanimelist.js "20" // 3. Top Anime: node myanimelist.js "top"
myanimelist.js(296 lines)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/**
* MyAnimeList.net Scraper
* Author: Vamz Spectre / VamxAPI
*
* Fitur:
* 1. Search Anime: Cari judul anime lengkap dengan poster HD, episode, skor, & sinopsis.
* 2. Detail Anime: Ambil metadata lengkap (judul, skor, ranking, studio, genre, sinopsis, trailer).
* 3. Top Anime: Ambil daftar anime dengan rating tertinggi di MyAnimeList.
*
* Penggunaan CLI:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/myanimelist" -o myanimelist.js
* node myanimelist.js "naruto"
* node myanimelist.js "https://myanimelist.net/anime/20/Naruto"
* node myanimelist.js "top"
*/
const axios = require('axios');
const cheerio = require('cheerio');
const BASE_URL = 'https://myanimelist.net';
const HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
};
function cleanImageUrl(imgUrl) {
if (!imgUrl) return '';
return imgUrl
.replace(/\/r\/\d+x\d+/, '')
.replace(/\?s=[a-zA-Z0-9]+/, '');
}
/**
* Cari anime berdasarkan kata kunci
* @param {string} query
*/
async function searchAnime(query) {
if (!query || typeof query !== 'string') {
throw new Error('Parameter query pencarian wajib diisi.');
}
const searchUrl = `${BASE_URL}/anime.php?q=${encodeURIComponent(query.trim())}`;
const response = await axios.get(searchUrl, {
headers: HEADERS,
timeout: 15000,
});
const $ = cheerio.load(response.data);
const results = [];
$('div.js-categories-seasonal table tr').each((_, el) => {
const cols = $(el).find('td');
if (cols.length < 5) return;
const imgEl = $(cols[0]).find('img');
const rawImg = imgEl.attr('data-src') || imgEl.attr('src') || '';
const image = cleanImageUrl(rawImg);
const titleAnchor = $(cols[1]).find('a').first();
const title = titleAnchor.find('strong').text().trim() || titleAnchor.text().trim();
const link = titleAnchor.attr('href') || '';
const synopsis = $(cols[1]).find('.pt4').text().trim();
const type = $(cols[2]).text().trim();
const episodes = $(cols[3]).text().trim();
const score = $(cols[4]).text().trim();
const idMatch = link.match(/\/anime\/(\d+)/);
const id = idMatch ? parseInt(idMatch[1], 10) : null;
if (title && link) {
results.push({
id,
title,
type,
episodes: episodes === '-' ? null : (parseInt(episodes, 10) || episodes),
score: score === '-' ? null : (parseFloat(score) || score),
image,
synopsis: synopsis || null,
url: link,
});
}
});
return {
status: true,
query,
total: results.length,
results,
};
}
/**
* Ambil detail lengkap anime berdasarkan ID atau URL
* @param {string|number} input
*/
async function getAnimeDetail(input) {
if (!input) {
throw new Error('Parameter input (URL atau Anime ID) wajib diisi.');
}
let detailUrl = '';
if (typeof input === 'number' || /^\d+$/.test(input.toString().trim())) {
detailUrl = `${BASE_URL}/anime/${input.toString().trim()}`;
} else if (input.toString().startsWith('http')) {
detailUrl = input.toString().trim();
} else {
// Jika bukan URL atau ID, anggap sebagai query pencarian pertama
const searchRes = await searchAnime(input.toString());
if (searchRes.results.length === 0) {
throw new Error(`Anime dengan kata kunci "${input}" tidak ditemukan.`);
}
detailUrl = searchRes.results[0].url;
}
const response = await axios.get(detailUrl, {
headers: HEADERS,
timeout: 15000,
});
const $ = cheerio.load(response.data);
const title = $('h1.title-name strong').text().trim() || $('h1.title-name').text().trim();
const englishTitle = $('p.title-english').text().trim() || null;
const japaneseTitle = $('.title-japanese').text().trim() || null;
const scoreText = $('.score-label').first().text().trim();
const score = scoreText ? (parseFloat(scoreText) || scoreText) : null;
const ranked = $('.ranked strong').text().trim() || null;
const popularity = $('.popularity strong').text().trim() || null;
const members = $('.members strong').text().trim() || null;
const posterImg = $('img[itemprop="image"]').attr('data-src') || $('img[itemprop="image"]').attr('src') || '';
const image = cleanImageUrl(posterImg);
const synopsis = $('p[itemprop="description"]').text().trim() || null;
const trailerIframe = $('.video-promotion a.iframe').attr('href') || null;
// Metadata sidebar
const meta = {};
$('.spaceit_pad').each((_, el) => {
const raw = $(el).text().replace(/\s+/g, ' ').trim();
const idx = raw.indexOf(':');
if (idx !== -1) {
const key = raw.slice(0, idx).trim();
const val = raw.slice(idx + 1).trim();
if (key && val) {
meta[key] = val;
}
}
});
const extractAnchors = (label) => {
let list = [];
$('.spaceit_pad').each((_, el) => {
const darkText = $(el).find('span.dark_text').text().trim().replace(':', '');
if (darkText.toLowerCase() === label.toLowerCase() || darkText.toLowerCase().startsWith(label.toLowerCase())) {
$(el).find('a').each((_, a) => {
const val = $(a).text().trim();
if (val && !list.includes(val)) list.push(val);
});
}
});
return list;
};
const idMatch = detailUrl.match(/\/anime\/(\d+)/);
const id = idMatch ? parseInt(idMatch[1], 10) : null;
const studios = extractAnchors('Studios');
const producers = extractAnchors('Producers');
const licensors = extractAnchors('Licensors');
const genres = extractAnchors('Genres').length > 0 ? extractAnchors('Genres') : extractAnchors('Genre');
const theme = extractAnchors('Theme').length > 0 ? extractAnchors('Theme') : extractAnchors('Themes');
return {
status: true,
id,
title,
englishTitle,
japaneseTitle,
score,
ranked,
popularity,
members,
type: meta['Type'] || null,
episodes: meta['Episodes'] ? (parseInt(meta['Episodes'], 10) || meta['Episodes']) : null,
statusAnime: meta['Status'] || null,
aired: meta['Aired'] || null,
premiered: meta['Premiered'] || null,
broadcast: meta['Broadcast'] || null,
producers,
licensors,
studios,
source: meta['Source'] || null,
genres,
theme,
duration: meta['Duration'] || null,
rating: meta['Rating'] || null,
trailerUrl: trailerIframe,
image,
synopsis,
url: detailUrl,
};
}
/**
* Ambil daftar Top Anime dari MyAnimeList
* @param {string} type - 'all' | 'airing' | 'upcoming' | 'tv' | 'movie' | 'ova' | 'special' | 'bypopularity' | 'favorite'
*/
async function getTopAnime(type = 'all') {
let url = `${BASE_URL}/topanime.php`;
if (type && type !== 'all') {
url += `?type=${encodeURIComponent(type)}`;
}
const response = await axios.get(url, {
headers: HEADERS,
timeout: 15000,
});
const $ = cheerio.load(response.data);
const results = [];
$('tr.ranking-list').each((_, el) => {
const rank = parseInt($(el).find('.rank span').text().trim(), 10) || null;
const titleAnchor = $(el).find('.detail h3 a');
const title = titleAnchor.text().trim();
const link = titleAnchor.attr('href') || '';
const imgEl = $(el).find('img');
const rawImg = imgEl.attr('data-src') || imgEl.attr('src') || '';
const image = cleanImageUrl(rawImg);
const score = parseFloat($(el).find('.score span').text().trim()) || null;
const infoText = $(el).find('.detail .information').text().replace(/\s+/g, ' ').trim();
const idMatch = link.match(/\/anime\/(\d+)/);
const id = idMatch ? parseInt(idMatch[1], 10) : null;
if (title && link) {
results.push({
rank,
id,
title,
score,
info: infoText,
image,
url: link,
});
}
});
return {
status: true,
category: type,
total: results.length,
results,
};
}
// Module Exports
module.exports = {
searchAnime,
getAnimeDetail,
getTopAnime,
};
// CLI Runner
if (require.main === module) {
const arg = process.argv[2] || 'naruto';
(async () => {
try {
let res;
if (arg.toLowerCase() === 'top' || arg.toLowerCase().startsWith('top:')) {
const type = arg.includes(':') ? arg.split(':')[1] : 'all';
res = await getTopAnime(type);
} else if (arg.startsWith('http') || /^\d+$/.test(arg)) {
res = await getAnimeDetail(arg);
} else {
res = await searchAnime(arg);
}
console.log(JSON.stringify(res, null, 2));
} catch (err) {
console.error(JSON.stringify({ status: false, error: err.message }, null, 2));
process.exit(1);
}
})();
}