Path: blob/master/node_modules/@bochilteam/scraper/lib/cjs/others/BMKG.js
1126 views
"use strict";1var __importDefault = (this && this.__importDefault) || function (mod) {2return (mod && mod.__esModule) ? mod : { "default": mod };3};4Object.defineProperty(exports, "__esModule", { value: true });5exports.tsunami = exports.gempaNow = exports.gempa = void 0;6const got_1 = __importDefault(require("got"));7const cheerio_1 = __importDefault(require("cheerio"));8async function gempa() {9const html = await (0, got_1.default)('https://www.bmkg.go.id/gempabumi/gempabumi-dirasakan.bmkg').text();10const $ = cheerio_1.default.load(html);11const results = [];12$('div.table-responsive > table.table > tbody > tr').each(function () {13const el = $(this).find('td');14const date = el.eq(1).text().trim();15const locate = el.eq(2).text().trim();16const magnitude = el.eq(3).text().trim();17const depth = el.eq(4).text().trim();18const location = el.eq(5).find('a').text().trim();19const warning = el.eq(5).find('span.label').map(function () {20return $(this).text().trim();21}).toArray();22results.push({23date,24locate,25magnitude,26depth,27location,28warning29});30});31return results;32}33exports.gempa = gempa;34async function gempaNow() {35const html = await (0, got_1.default)('https://www.bmkg.go.id/gempabumi/gempabumi-terkini.bmkg').text();36const $ = cheerio_1.default.load(html);37const results = [];38$('div.table-responsive > table.table > tbody > tr').each(function () {39const el = $(this).find('td');40const date = el.eq(1).text().trim();41const latitude = el.eq(2).text().trim();42const longitude = el.eq(3).text().trim();43const magnitude = el.eq(4).text().trim();44const depth = el.eq(5).text().trim();45const location = el.eq(6).text().trim();46results.push({47date,48latitude,49longitude,50magnitude,51depth,52location53});54});55return results;56}57exports.gempaNow = gempaNow;58async function tsunami() {59const html = await (0, got_1.default)('https://www.bmkg.go.id/tsunami/').text();60const $ = cheerio_1.default.load(html);61const results = [];62$('div.row > div > table.table > tbody > tr').each(function () {63const el = $(this).find('td');64const date = el.eq(0).text().trim();65const locate = el.eq(1).text().trim();66const magnitude = el.eq(2).text().trim();67const depth = el.eq(3).text().trim();68const location = el.eq(4).text().trim();69results.push({70date,71locate,72magnitude,73depth,74location75});76});77return results;78}79exports.tsunami = tsunami;80//# sourceMappingURL=BMKG.js.map8182