forked from wafarifki/Hacktoberfest_2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anime.js
23 lines (22 loc) · 897 Bytes
/
anime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const axios = require('axios')
function anime(query) {
return new Promise((resolve, reject) => {
axios.get(`https://www.anime-planet.com/anime/all?name=${query}`)
.then(({
data
}) => {
const hasil = []
const $ = cheerio.load(data)
$('#siteContainer > ul.cardDeck.cardGrid > li ').each(function (a, b) {
result = {
judul: $(b).find('> a > h3').text(),
link: 'https://www.anime-planet.com' + $(b).find('> a').attr('href'),
thumbnail: 'https://www.anime-planet.com' + $(b).find('> a > div.crop > img').attr('src')
};
hasil.push(result);
});
resolve(hasil)
})
.catch(reject)
})
}