@aidarkezio/main-func
Version:
📦 It has my funcs
29 lines • 1.11 kB
JavaScript
import got from 'got';
import cheerio from 'cheerio';
export default async function kompas() {
const html = await got('https://www.kompas.com/').text();
const $ = cheerio.load(html);
const result = [];
$('div.latest.ga--latest').each((_, el) => {
$(el).find('div.article__list').each((_, el) => {
const $el = $(el);
const title = $el.find('h3 > a.article__link').text();
const link = $el.find('h3 > a.article__link').attr('href');
const $image = $el.find('.article__asset > a > img');
const image = ($image.attr('src') || $image.attr('data-src'));
const label = $el.find('.article__list__info > .article__subtitle').text();
const date = $el.find('.article__list__info > .article__date').text();
if (title && link) {
result.push({
title,
link,
image,
label,
date
});
}
});
});
return result;
}
//# sourceMappingURL=kompas.js.map