Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/news/kompas.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export default async function kompas() {
4
const html = await got('https://www.kompas.com/').text();
5
const $ = cheerio.load(html);
6
const result = [];
7
$('div.latest.ga--latest').each((_, el) => {
8
$(el).find('div.article__list').each((_, el) => {
9
const $el = $(el);
10
const title = $el.find('h3 > a.article__link').text();
11
const link = $el.find('h3 > a.article__link').attr('href');
12
const $image = $el.find('.article__asset > a > img');
13
const image = ($image.attr('src') || $image.attr('data-src'));
14
const label = $el.find('.article__list__info > .article__subtitle').text();
15
const date = $el.find('.article__list__info > .article__date').text();
16
if (title && link) {
17
result.push({
18
title,
19
link,
20
image,
21
label,
22
date
23
});
24
}
25
});
26
});
27
return result;
28
}
29
//# sourceMappingURL=kompas.js.map
30