Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/cjs/news/kompas.js
1126 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
const got_1 = __importDefault(require("got"));
7
const cheerio_1 = __importDefault(require("cheerio"));
8
async function kompas() {
9
const html = await (0, got_1.default)('https://www.kompas.com/').text();
10
const $ = cheerio_1.default.load(html);
11
const result = [];
12
$('div.latest.ga--latest').each((_, el) => {
13
$(el).find('div.article__list').each((_, el) => {
14
const $el = $(el);
15
const title = $el.find('h3 > a.article__link').text();
16
const link = $el.find('h3 > a.article__link').attr('href');
17
const $image = $el.find('.article__asset > a > img');
18
const image = ($image.attr('src') || $image.attr('data-src'));
19
const label = $el.find('.article__list__info > .article__subtitle').text();
20
const date = $el.find('.article__list__info > .article__date').text();
21
if (title && link) {
22
result.push({
23
title,
24
link,
25
image,
26
label,
27
date
28
});
29
}
30
});
31
});
32
return result;
33
}
34
exports.default = kompas;
35
//# sourceMappingURL=kompas.js.map
36