-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathjagokata.js
22 lines (21 loc) · 948 Bytes
/
jagokata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const cheerio from 'cheerio'
const fetch from 'node-fetch'
export.default = function quotes(input) {
return new Promise((resolve, reject) => {
fetch('https://jagokata.com/kata-bijak/kata-' + input.replace(/\s/g, '_') + '.html?page=1')
.then(res => res.text())
.then(res => {
const $ = cheerio.load(res)
data = []
$('div[id="main"]').find('ul[id="citatenrijen"] > li').each(function (index, element) {
x = $(this).find('div[class="citatenlijst-auteur"] > a').text().trim()
y = $(this).find('span[class="auteur-beschrijving"]').text().trim()
z = $(element).find('q[class="fbquote"]').text().trim()
data.push({ author: x, bio: y, quote: z })
})
data.splice(2, 1)
if (data.length == 0) return resolve({ creator: '@neoxr - Wildan Izzudin & @ariffb.id - Ariffb', status: false })
resolve({ creator: '@neoxr - Wildan Izzudin & @ariffb.id - Ariffb', status: true, data })
}).catch(reject)
})
}