forked from spandey1296/CODEMONK-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
umma.js
28 lines (26 loc) Β· 1.27 KB
/
umma.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
const axios = require('axios')
const cheerio = require('cheerio')
function umma(url) {
return new Promise((resolve, reject) => {
axios.get(url)
.then((res) => {
let $ = cheerio.load(res.data)
let image = []
$('#article-content > div').find('img').each(function (a, b) {
image.push($(b).attr('src'))
})
let hasil = {
title: $('#wrap > div.content-container.font-6-16 > h1').text().trim(),
author: {
name: $('#wrap > div.content-container.font-6-16 > div.content-top > div > div.user-ame.font-6-16.fw').text().trim(),
profilePic: $('#wrap > div.content-container.font-6-16 > div.content-top > div > div.profile-photo > img.photo').attr('src')
},
caption: $('#article-content > div > p').text().trim(),
media: $('#article-content > div > iframe').attr('src') ? [$('#article-content > div > iframe').attr('src')] : image,
type: $('#article-content > div > iframe').attr('src') ? 'video' : 'image',
like: $('#wrap > div.bottom-btns > div > button:nth-child(1) > div.text.font-6-12').text(),
}
resolve(hasil)
})
})
}