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/liputan6.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export default async function liputan6() {
4
const html = await got('https://www.liputan6.com/').text();
5
const $ = cheerio.load(html);
6
const results = [];
7
$('div.articles > div.articles--iridescent-list').each((i, el) => {
8
$(el).find('article.articles--iridescent-list--item').each((i, el) => {
9
const $el = $(el);
10
const title = $el.find('span.articles--iridescent-list--text-item__title-link-text').text();
11
const link = $el.find('a.ui--a[data-template-var="url"]').attr('href');
12
const description = $el.find('div.articles--iridescent-list--text-item__summary').text();
13
const $image = $el.find('picture.articles--iridescent-list--text-item__figure-image > img');
14
const image = ($image.attr('src') || $image.attr('data-src') || $image.attr('data-high-dpi'));
15
const label = $el.find('a.articles--iridescent-list--text-item__category').text();
16
const $date = $el.find('time.articles--iridescent-list--text-item__time');
17
const date = $date.attr('datetime') || $date.attr('title') || $date.text();
18
if (title && link) {
19
results.push({
20
title,
21
link,
22
image,
23
description,
24
label,
25
date
26
});
27
}
28
});
29
});
30
return results;
31
}
32
//# sourceMappingURL=liputan6.js.map
33