@bochilteam/scraper-religions
Advanced tools
Comparing version 1.0.2 to 5.0.0
import { AlQuran } from '../types/index.js'; | ||
/** | ||
* Inspiration from https://github.com/rzkytmgr/quran-api | ||
*/ | ||
export declare function alquran(): Promise<AlQuran[]>; | ||
//# sourceMappingURL=alquran.d.ts.map |
@@ -1,4 +0,10 @@ | ||
import { JadwalSholat, JadwalSholatItem } from '../types/index.js'; | ||
export declare const listJadwalSholat: Promise<JadwalSholatItem[]>; | ||
import { JadwalSholat } from '../types/index.js'; | ||
export declare const listJadwalSholat: Promise<{ | ||
value: string; | ||
kota: string; | ||
}[]>; | ||
/** | ||
* Scrape from https://www.jadwalsholat.org/ | ||
*/ | ||
export default function jadwalsholat(kota: string): Promise<JadwalSholat>; | ||
//# sourceMappingURL=jadwalsholat.d.ts.map |
@@ -133,7 +133,7 @@ import { z } from 'zod'; | ||
}, "strip", z.ZodTypeAny, { | ||
obligatory: boolean; | ||
recomended?: boolean | undefined; | ||
}, { | ||
obligatory: boolean; | ||
}, { | ||
recomended?: boolean | undefined; | ||
obligatory: boolean; | ||
}>; | ||
@@ -196,4 +196,4 @@ text: z.ZodObject<{ | ||
sajda: { | ||
obligatory: boolean; | ||
recomended?: boolean | undefined; | ||
obligatory: boolean; | ||
}; | ||
@@ -226,4 +226,4 @@ text: { | ||
sajda: { | ||
obligatory: boolean; | ||
recomended?: boolean | undefined; | ||
obligatory: boolean; | ||
}; | ||
@@ -239,3 +239,2 @@ text: { | ||
}, "strip", z.ZodTypeAny, { | ||
ayatCount?: number | undefined; | ||
number: number; | ||
@@ -293,4 +292,4 @@ type: { | ||
sajda: { | ||
obligatory: boolean; | ||
recomended?: boolean | undefined; | ||
obligatory: boolean; | ||
}; | ||
@@ -305,4 +304,4 @@ text: { | ||
}[]; | ||
ayatCount?: number | undefined; | ||
}, { | ||
ayatCount?: number | undefined; | ||
number: number; | ||
@@ -360,4 +359,4 @@ type: { | ||
sajda: { | ||
obligatory: boolean; | ||
recomended?: boolean | undefined; | ||
obligatory: boolean; | ||
}; | ||
@@ -372,2 +371,3 @@ text: { | ||
}[]; | ||
ayatCount?: number | undefined; | ||
}>; | ||
@@ -421,4 +421,6 @@ export type AlQuran = z.infer<typeof AlQuranSchema>; | ||
date: z.ZodString; | ||
today: z.ZodRecord<z.ZodString, z.ZodString>; | ||
list: z.ZodArray<z.ZodObject<{ | ||
location: z.ZodString; | ||
direction: z.ZodString; | ||
distance: z.ZodString; | ||
schedules: z.ZodArray<z.ZodObject<{ | ||
date: z.ZodString; | ||
@@ -431,4 +433,4 @@ imsyak: z.ZodString; | ||
ashr: z.ZodString; | ||
magrib: z.ZodString; | ||
isyak: z.ZodString; | ||
maghrib: z.ZodString; | ||
isya: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -442,4 +444,4 @@ date: string; | ||
ashr: string; | ||
magrib: string; | ||
isyak: string; | ||
maghrib: string; | ||
isya: string; | ||
}, { | ||
@@ -453,9 +455,11 @@ date: string; | ||
ashr: string; | ||
magrib: string; | ||
isyak: string; | ||
maghrib: string; | ||
isya: string; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
date: string; | ||
today: Record<string, string>; | ||
list: { | ||
location: string; | ||
direction: string; | ||
distance: string; | ||
schedules: { | ||
date: string; | ||
@@ -468,9 +472,11 @@ imsyak: string; | ||
ashr: string; | ||
magrib: string; | ||
isyak: string; | ||
maghrib: string; | ||
isya: string; | ||
}[]; | ||
}, { | ||
date: string; | ||
today: Record<string, string>; | ||
list: { | ||
location: string; | ||
direction: string; | ||
distance: string; | ||
schedules: { | ||
date: string; | ||
@@ -483,4 +489,4 @@ imsyak: string; | ||
ashr: string; | ||
magrib: string; | ||
isyak: string; | ||
maghrib: string; | ||
isya: string; | ||
}[]; | ||
@@ -514,2 +520,4 @@ }>; | ||
}, "strip", z.ZodTypeAny, { | ||
0: string; | ||
1: string[]; | ||
2?: { | ||
@@ -521,5 +529,5 @@ threshold?: number | undefined; | ||
} | undefined; | ||
}, { | ||
0: string; | ||
1: string[]; | ||
}, { | ||
2?: { | ||
@@ -531,4 +539,2 @@ threshold?: number | undefined; | ||
} | undefined; | ||
0: string; | ||
1: string[]; | ||
}>; | ||
@@ -535,0 +541,0 @@ export declare const DidYouMeanSchema: z.ZodObject<{ |
@@ -9,6 +9,9 @@ "use strict"; | ||
const index_js_1 = require("../types/index.js"); | ||
/** | ||
* Inspiration from https://github.com/rzkytmgr/quran-api | ||
*/ | ||
async function alquran() { | ||
const data = await (0, got_1.default)('https://raw.githubusercontent.com/rzkytmgr/quran-api/master/data/quran.json').json(); | ||
const data = await (0, got_1.default)('https://github.com/rzkytmgr/quran-api/raw/deprecated/data/quran.json').json(); | ||
return data.map(item => index_js_1.AlQuranSchema.parse(item)); | ||
} | ||
exports.alquran = alquran; |
@@ -11,3 +11,6 @@ "use strict"; | ||
const index_js_2 = require("../types/index.js"); | ||
exports.listJadwalSholat = (async () => (0, got_1.default)('https://raw.githubusercontent.com/BochilTeam/scraper/master/data/jadwal-sholat.json').json())(); | ||
exports.listJadwalSholat = (async () => (0, got_1.default)('https://github.com/BochilTeam/scraper/raw/master/data/jadwal-sholat.json').json())(); | ||
/** | ||
* Scrape from https://www.jadwalsholat.org/ | ||
*/ | ||
async function jadwalsholat(kota) { | ||
@@ -24,20 +27,12 @@ index_js_2.JadwalSholatArgsSchema.parse(arguments); | ||
index_js_2.JadwalSholatItemSchema.parse(jadwal); | ||
const today = await (0, got_1.default)(`https://www.jadwalsholat.org/adzan/ajax/ajax.daily1.php?id=${jadwal.value}`).text(); | ||
const sholatToday = {}; | ||
const $ = cheerio_1.default.load(today); | ||
$('table > tbody > tr') | ||
.filter('.table_light, .table_dark') | ||
.each(function () { | ||
const data = await (0, got_1.default)(`https://jadwalsholat.org/jadwal-sholat/monthly.php?id=${jadwal.value}`).text(); | ||
const $ = cheerio_1.default.load(data); | ||
const date = $('tr.table_title > td > h2.h2_edit').text().trim(); | ||
const location = $('tr.table_block_content > td[colspan=7]').html().split('</b>')[1].trim(); | ||
const direction = $('tr.table_block_content > td[colspan=5]').eq(0).text().split('ke')[0].trim(); | ||
const distance = $('tr.table_block_content > td[colspan=5]').eq(1).text().split('ke')[0].trim(); | ||
const schedules = $('tbody > tr[align=center]') | ||
.filter('.table_highlight, .table_light, .table_dark') | ||
.map(function () { | ||
const el = $(this).find('td'); | ||
const sholat = el.eq(0).text(); | ||
const time = el.eq(1).text(); | ||
sholatToday[sholat] = time; | ||
}); | ||
const data = await (0, got_1.default)(`https://jadwalsholat.org/jadwal-sholat/monthly.php?id=${jadwal.value}`).text(); | ||
const list = []; | ||
const $$ = cheerio_1.default.load(data); | ||
$$('table.table_adzan > tbody > tr') | ||
.filter('.table_light, .table_dark') | ||
.each(function () { | ||
const el = $$(this).find('td'); | ||
const date = el.eq(0).text().trim(); | ||
@@ -50,5 +45,5 @@ const imsyak = el.eq(1).text().trim(); | ||
const ashr = el.eq(6).text().trim(); | ||
const magrib = el.eq(7).text().trim(); | ||
const isyak = el.eq(8).text().trim(); | ||
list.push({ | ||
const maghrib = el.eq(7).text().trim(); | ||
const isya = el.eq(8).text().trim(); | ||
return { | ||
date, | ||
@@ -61,10 +56,12 @@ imsyak, | ||
ashr, | ||
magrib, | ||
isyak | ||
}); | ||
}); | ||
maghrib, | ||
isya | ||
}; | ||
}).toArray(); | ||
const result = { | ||
date: $$('tr.table_title > td > h2.h2_edit').text().trim(), | ||
today: sholatToday, | ||
list | ||
date, | ||
location, | ||
direction, | ||
distance, | ||
schedules | ||
}; | ||
@@ -71,0 +68,0 @@ return index_js_2.JadwalSholatSchema.parse(result); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mocha_1 = require("mocha"); | ||
const chai_1 = require("chai"); | ||
const node_test_1 = require("node:test"); | ||
const node_assert_1 = __importDefault(require("node:assert")); | ||
const index_js_1 = require("../index.js"); | ||
(0, mocha_1.describe)('Religions', () => { | ||
(0, mocha_1.describe)('Asmaul Husna', () => { | ||
(0, mocha_1.it)('AsmaulHusna', done => { | ||
(0, index_js_1.asmaulhusna)().then(res => { | ||
return done(); | ||
}).catch(done); | ||
(0, node_test_1.describe)('Religions', () => { | ||
(0, node_test_1.describe)('Asmaul Husna', () => { | ||
(0, node_test_1.it)('AsmaulHusna', async () => { | ||
const data = await (0, index_js_1.asmaulhusna)(6); | ||
node_assert_1.default.strictEqual(data.latin, 'Al Muhaimin'); | ||
node_assert_1.default.strictEqual(data.arabic, 'الْمُهَيْمِنُ'); | ||
node_assert_1.default.strictEqual(data.translation_id, 'Yang Memiliki Mutlak sifat Pemelihara'); | ||
node_assert_1.default.strictEqual(data.translation_en, 'The Guardian, the Preserver'); | ||
}); | ||
(0, mocha_1.it)('AsmaulHusna JSON', done => { | ||
const res = index_js_1.asmaulhusnajson; | ||
(0, chai_1.expect)(res).to.have.length(99); | ||
return done(); | ||
(0, node_test_1.it)('AsmaulHusna JSON', () => { | ||
const data = index_js_1.asmaulhusnajson; | ||
node_assert_1.default.ok(data.length === 99); | ||
}); | ||
}); | ||
(0, mocha_1.describe)('Al quran', function () { | ||
this.timeout(10000); | ||
(0, mocha_1.it)('Alquran', done => { | ||
(0, index_js_1.alquran)().then(res => { | ||
(0, chai_1.expect)(res).to.have.length(114); | ||
return done(); | ||
}).catch(done); | ||
(0, node_test_1.describe)('Al quran', () => { | ||
(0, node_test_1.it)('Alquran', async () => { | ||
const data = await (0, index_js_1.alquran)(); | ||
node_assert_1.default.ok(data.length === 114); | ||
}); | ||
}); | ||
(0, mocha_1.describe)('Jadwal Sholat', function () { | ||
this.timeout(5000); | ||
(0, mocha_1.it)('jadwalSholat', done => { | ||
(0, index_js_1.jadwalsholat)('Semarang').then(res => { | ||
(0, chai_1.expect)(res.list).to.have.lengthOf.at.least(27); | ||
return done(); | ||
}).catch(done); | ||
(0, node_test_1.describe)('Jadwal Sholat', () => { | ||
(0, node_test_1.it)('jadwalSholat', async () => { | ||
const data = await (0, index_js_1.jadwalsholat)('Semarang'); | ||
node_assert_1.default.strictEqual(data.location, '6°58\' LS 110°29\' BT'); | ||
node_assert_1.default.strictEqual(data.direction, '294.48 °'); | ||
node_assert_1.default.strictEqual(data.distance, '8323.049 km'); | ||
node_assert_1.default.ok(data.schedules.length > 27); | ||
}); | ||
(0, mocha_1.it)('List jadwal sholat', done => { | ||
Promise.resolve(index_js_1.listJadwalSholat).then(res => { | ||
(0, chai_1.expect)(res).to.have.lengthOf.at.least(316); | ||
return done(); | ||
}).catch(done); | ||
(0, node_test_1.it)('List jadwal sholat', async () => { | ||
const data = await index_js_1.listJadwalSholat; | ||
node_assert_1.default.ok(data.length >= 316); | ||
}); | ||
}); | ||
}); |
@@ -81,4 +81,6 @@ "use strict"; | ||
date: zod_1.z.string(), | ||
today: zod_1.z.record(zod_1.z.string()), | ||
list: zod_1.z.object({ | ||
location: zod_1.z.string(), | ||
direction: zod_1.z.string(), | ||
distance: zod_1.z.string(), | ||
schedules: zod_1.z.object({ | ||
date: zod_1.z.string(), | ||
@@ -91,4 +93,4 @@ imsyak: zod_1.z.string(), | ||
ashr: zod_1.z.string(), | ||
magrib: zod_1.z.string(), | ||
isyak: zod_1.z.string() | ||
maghrib: zod_1.z.string(), | ||
isya: zod_1.z.string() | ||
}).array() | ||
@@ -95,0 +97,0 @@ }); |
import got from 'got'; | ||
import { AlQuranSchema } from '../types/index.js'; | ||
/** | ||
* Inspiration from https://github.com/rzkytmgr/quran-api | ||
*/ | ||
export async function alquran() { | ||
const data = await got('https://raw.githubusercontent.com/rzkytmgr/quran-api/master/data/quran.json').json(); | ||
const data = await got('https://github.com/rzkytmgr/quran-api/raw/deprecated/data/quran.json').json(); | ||
return data.map(item => AlQuranSchema.parse(item)); | ||
} |
@@ -5,3 +5,6 @@ import cheerio from 'cheerio'; | ||
import { JadwalSholatArgsSchema, JadwalSholatItemSchema, JadwalSholatSchema } from '../types/index.js'; | ||
export const listJadwalSholat = (async () => got('https://raw.githubusercontent.com/BochilTeam/scraper/master/data/jadwal-sholat.json').json())(); | ||
export const listJadwalSholat = (async () => got('https://github.com/BochilTeam/scraper/raw/master/data/jadwal-sholat.json').json())(); | ||
/** | ||
* Scrape from https://www.jadwalsholat.org/ | ||
*/ | ||
export default async function jadwalsholat(kota) { | ||
@@ -18,20 +21,12 @@ JadwalSholatArgsSchema.parse(arguments); | ||
JadwalSholatItemSchema.parse(jadwal); | ||
const today = await got(`https://www.jadwalsholat.org/adzan/ajax/ajax.daily1.php?id=${jadwal.value}`).text(); | ||
const sholatToday = {}; | ||
const $ = cheerio.load(today); | ||
$('table > tbody > tr') | ||
.filter('.table_light, .table_dark') | ||
.each(function () { | ||
const data = await got(`https://jadwalsholat.org/jadwal-sholat/monthly.php?id=${jadwal.value}`).text(); | ||
const $ = cheerio.load(data); | ||
const date = $('tr.table_title > td > h2.h2_edit').text().trim(); | ||
const location = $('tr.table_block_content > td[colspan=7]').html().split('</b>')[1].trim(); | ||
const direction = $('tr.table_block_content > td[colspan=5]').eq(0).text().split('ke')[0].trim(); | ||
const distance = $('tr.table_block_content > td[colspan=5]').eq(1).text().split('ke')[0].trim(); | ||
const schedules = $('tbody > tr[align=center]') | ||
.filter('.table_highlight, .table_light, .table_dark') | ||
.map(function () { | ||
const el = $(this).find('td'); | ||
const sholat = el.eq(0).text(); | ||
const time = el.eq(1).text(); | ||
sholatToday[sholat] = time; | ||
}); | ||
const data = await got(`https://jadwalsholat.org/jadwal-sholat/monthly.php?id=${jadwal.value}`).text(); | ||
const list = []; | ||
const $$ = cheerio.load(data); | ||
$$('table.table_adzan > tbody > tr') | ||
.filter('.table_light, .table_dark') | ||
.each(function () { | ||
const el = $$(this).find('td'); | ||
const date = el.eq(0).text().trim(); | ||
@@ -44,5 +39,5 @@ const imsyak = el.eq(1).text().trim(); | ||
const ashr = el.eq(6).text().trim(); | ||
const magrib = el.eq(7).text().trim(); | ||
const isyak = el.eq(8).text().trim(); | ||
list.push({ | ||
const maghrib = el.eq(7).text().trim(); | ||
const isya = el.eq(8).text().trim(); | ||
return { | ||
date, | ||
@@ -55,12 +50,14 @@ imsyak, | ||
ashr, | ||
magrib, | ||
isyak | ||
}); | ||
}); | ||
maghrib, | ||
isya | ||
}; | ||
}).toArray(); | ||
const result = { | ||
date: $$('tr.table_title > td > h2.h2_edit').text().trim(), | ||
today: sholatToday, | ||
list | ||
date, | ||
location, | ||
direction, | ||
distance, | ||
schedules | ||
}; | ||
return JadwalSholatSchema.parse(result); | ||
} |
@@ -1,41 +0,37 @@ | ||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'node:test'; | ||
import assert from 'node:assert'; | ||
import { asmaulhusna, asmaulhusnajson, alquran, jadwalsholat, listJadwalSholat } from '../index.js'; | ||
describe('Religions', () => { | ||
describe('Asmaul Husna', () => { | ||
it('AsmaulHusna', done => { | ||
asmaulhusna().then(res => { | ||
return done(); | ||
}).catch(done); | ||
it('AsmaulHusna', async () => { | ||
const data = await asmaulhusna(6); | ||
assert.strictEqual(data.latin, 'Al Muhaimin'); | ||
assert.strictEqual(data.arabic, 'الْمُهَيْمِنُ'); | ||
assert.strictEqual(data.translation_id, 'Yang Memiliki Mutlak sifat Pemelihara'); | ||
assert.strictEqual(data.translation_en, 'The Guardian, the Preserver'); | ||
}); | ||
it('AsmaulHusna JSON', done => { | ||
const res = asmaulhusnajson; | ||
expect(res).to.have.length(99); | ||
return done(); | ||
it('AsmaulHusna JSON', () => { | ||
const data = asmaulhusnajson; | ||
assert.ok(data.length === 99); | ||
}); | ||
}); | ||
describe('Al quran', function () { | ||
this.timeout(10000); | ||
it('Alquran', done => { | ||
alquran().then(res => { | ||
expect(res).to.have.length(114); | ||
return done(); | ||
}).catch(done); | ||
describe('Al quran', () => { | ||
it('Alquran', async () => { | ||
const data = await alquran(); | ||
assert.ok(data.length === 114); | ||
}); | ||
}); | ||
describe('Jadwal Sholat', function () { | ||
this.timeout(5000); | ||
it('jadwalSholat', done => { | ||
jadwalsholat('Semarang').then(res => { | ||
expect(res.list).to.have.lengthOf.at.least(27); | ||
return done(); | ||
}).catch(done); | ||
describe('Jadwal Sholat', () => { | ||
it('jadwalSholat', async () => { | ||
const data = await jadwalsholat('Semarang'); | ||
assert.strictEqual(data.location, '6°58\' LS 110°29\' BT'); | ||
assert.strictEqual(data.direction, '294.48 °'); | ||
assert.strictEqual(data.distance, '8323.049 km'); | ||
assert.ok(data.schedules.length > 27); | ||
}); | ||
it('List jadwal sholat', done => { | ||
Promise.resolve(listJadwalSholat).then(res => { | ||
expect(res).to.have.lengthOf.at.least(316); | ||
return done(); | ||
}).catch(done); | ||
it('List jadwal sholat', async () => { | ||
const data = await listJadwalSholat; | ||
assert.ok(data.length >= 316); | ||
}); | ||
}); | ||
}); |
@@ -78,4 +78,6 @@ import { z } from 'zod'; | ||
date: z.string(), | ||
today: z.record(z.string()), | ||
list: z.object({ | ||
location: z.string(), | ||
direction: z.string(), | ||
distance: z.string(), | ||
schedules: z.object({ | ||
date: z.string(), | ||
@@ -88,4 +90,4 @@ imsyak: z.string(), | ||
ashr: z.string(), | ||
magrib: z.string(), | ||
isyak: z.string() | ||
maghrib: z.string(), | ||
isya: z.string() | ||
}).array() | ||
@@ -92,0 +94,0 @@ }); |
{ | ||
"name": "@bochilteam/scraper-religions", | ||
"version": "1.0.2", | ||
"version": "5.0.0", | ||
"description": "Religions scraper module", | ||
@@ -17,4 +17,4 @@ "main": "lib/cjs/index.js", | ||
"test": "npm run test:cjs & npm run test:esm", | ||
"test:cjs": "mocha ./lib/cjs/test/*.js", | ||
"test:esm": "mocha ./lib/esm/test/*.js", | ||
"test:cjs": "node --test ./lib/cjs/test/", | ||
"test:esm": "node --test ./lib/esm/test/", | ||
"build": "npm run build:cjs && npm run build:esm && npm run build:types", | ||
@@ -49,9 +49,5 @@ "build:cjs": "tsc -p tsconfig.cjs.json", | ||
"devDependencies": { | ||
"@types/chai": "^4.3.5", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.11.17", | ||
"@types/similarity": "^1.2.1", | ||
"chai": "^4.3.7", | ||
"mocha": "^10.2.0" | ||
"@types/node": "^20.14.9", | ||
"@types/similarity": "^1.2.1" | ||
} | ||
} | ||
} |
2
38165
25
1131