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/antaranews.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export default async function antaranews() {
4
const html = await got('https://www.antaranews.com/').text();
5
const $ = cheerio.load(html);
6
const results = [];
7
$('div.terkini > article.simple-post').each((_, el) => {
8
const $el = $(el);
9
const title = $el.find('.latest-news > a').text();
10
const link = $el.find('.latest-news > a').attr('href');
11
const $image = $el.find('picture');
12
const image = $image.find('img').attr('src') ||
13
$image.find('img').attr('data-src') ||
14
$image.find('source').attr('srcset') ||
15
$image.find('source').attr('data-srcset');
16
const label = $el.find('.simple-share').text();
17
const date = $el.find('.simple-share > span').text();
18
if (title && image) {
19
results.push({
20
title,
21
link,
22
image,
23
label: label.replace(date, '').replace('/', '').trim(),
24
date: date.trim()
25
});
26
}
27
});
28
return results;
29
}
30
//# sourceMappingURL=antaranews.js.map
31