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/cnbcindonesia.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export default async function cnbindonesia() {
4
const html = await got('https://www.cnbcindonesia.com/news').text();
5
const $ = cheerio.load(html);
6
const results = [];
7
$('body > div.container > div > ul.list > li').each((_, el) => {
8
const $el = $(el);
9
const title = $el.find('.box_text > h2').text();
10
const subtitle = $el.find('.box_text > .subjudul').text() || undefined;
11
const link = $el.find('a').attr('href');
12
const image = $el.find('span > img').attr('src');
13
const label = $el.find('.date > .label').text();
14
const date = $el.find('.date').text().replace(label, '').replace('-', '').trim();
15
if (title && link) {
16
results.push({
17
title,
18
subtitle,
19
link,
20
image,
21
label,
22
date
23
});
24
}
25
});
26
return results;
27
}
28
//# sourceMappingURL=cnbcindonesia.js.map
29