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