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/merdeka.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export default async function merdeka() {
4
const html = await got('https://www.merdeka.com/berita-hari-ini/').text();
5
const $ = cheerio.load(html);
6
const results = [];
7
$('div.main_photo_center > div.mdk-tag-contg').each((_, el) => {
8
const $el = $(el);
9
const title = $el.find('div.mdk-tag-contln-l > a[title]').attr('title');
10
const link = $el.find('div.mdk-tag-contln-l > a[title]').attr('href');
11
const image = $el.find('div.mdk-tag-contln-l > a[title] > img').attr('src');
12
const label = $el.find('div.mdk-tag-contln-date > span').text();
13
const date = $el.find('div.mdk-tag-contln-date').text();
14
if (title) {
15
results.push({
16
title,
17
link: 'https://www.merdeka.com' + link,
18
image,
19
label,
20
date: date.replace(label, '').replace('Sekitar', '').trim()
21
});
22
}
23
});
24
return results;
25
}
26
//# sourceMappingURL=merdeka.js.map
27