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/religions/jadwalsholat.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
exports.listJadwalSholat = void 0;
7
const cheerio_1 = __importDefault(require("cheerio"));
8
const got_1 = __importDefault(require("got"));
9
const utils_js_1 = require("../utils.js");
10
exports.listJadwalSholat = (async () => (0, got_1.default)('https://raw.githubusercontent.com/BochilTeam/scraper/master/data/jadwal-sholat.json').json())();
11
async function jadwalsholat(kota) {
12
const listJadwal = await exports.listJadwalSholat;
13
let jadwal;
14
if (!(jadwal = listJadwal.find(({ kota: Kota }) => new RegExp(Kota, 'ig').test(kota)))) {
15
throw new utils_js_1.ScraperError('List kota ' + listJadwal.map(({ kota }) => kota));
16
}
17
const today = await (0, got_1.default)(`https://www.jadwalsholat.org/adzan/ajax/ajax.daily1.php?id=${jadwal.value}`).text();
18
const sholatToday = {};
19
const $ = cheerio_1.default.load(today);
20
$('table > tbody > tr')
21
.filter('.table_light, .table_dark')
22
.each(function () {
23
const el = $(this).find('td');
24
const sholat = el.eq(0).text();
25
const time = el.eq(1).text();
26
sholatToday[sholat] = time;
27
});
28
const data = await (0, got_1.default)(`https://jadwalsholat.org/jadwal-sholat/monthly.php?id=${jadwal.value}`).text();
29
const list = [];
30
const $$ = cheerio_1.default.load(data);
31
$$('table.table_adzan > tbody > tr')
32
.filter('.table_light, .table_dark')
33
.each(function () {
34
const el = $$(this).find('td');
35
const date = el.eq(0).text().trim();
36
const imsyak = el.eq(1).text().trim();
37
const shubuh = el.eq(2).text().trim();
38
const terbit = el.eq(3).text().trim();
39
const dhuha = el.eq(4).text().trim();
40
const dzuhur = el.eq(5).text().trim();
41
const ashr = el.eq(6).text().trim();
42
const magrib = el.eq(7).text().trim();
43
const isyak = el.eq(8).text().trim();
44
list.push({
45
date,
46
imsyak,
47
shubuh,
48
terbit,
49
dhuha,
50
dzuhur,
51
ashr,
52
magrib,
53
isyak
54
});
55
});
56
return {
57
date: $$('tr.table_title > td > h2.h2_edit').text().trim(),
58
today: sholatToday,
59
list
60
};
61
}
62
exports.default = jadwalsholat;
63
//# sourceMappingURL=jadwalsholat.js.map
64