Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/others/BMKG.js
1126 views
import got from 'got';1import cheerio from 'cheerio';2export async function gempa() {3const html = await got('https://www.bmkg.go.id/gempabumi/gempabumi-dirasakan.bmkg').text();4const $ = cheerio.load(html);5const results = [];6$('div.table-responsive > table.table > tbody > tr').each(function () {7const el = $(this).find('td');8const date = el.eq(1).text().trim();9const locate = el.eq(2).text().trim();10const magnitude = el.eq(3).text().trim();11const depth = el.eq(4).text().trim();12const location = el.eq(5).find('a').text().trim();13const warning = el.eq(5).find('span.label').map(function () {14return $(this).text().trim();15}).toArray();16results.push({17date,18locate,19magnitude,20depth,21location,22warning23});24});25return results;26}27export async function gempaNow() {28const html = await got('https://www.bmkg.go.id/gempabumi/gempabumi-terkini.bmkg').text();29const $ = cheerio.load(html);30const results = [];31$('div.table-responsive > table.table > tbody > tr').each(function () {32const el = $(this).find('td');33const date = el.eq(1).text().trim();34const latitude = el.eq(2).text().trim();35const longitude = el.eq(3).text().trim();36const magnitude = el.eq(4).text().trim();37const depth = el.eq(5).text().trim();38const location = el.eq(6).text().trim();39results.push({40date,41latitude,42longitude,43magnitude,44depth,45location46});47});48return results;49}50export async function tsunami() {51const html = await got('https://www.bmkg.go.id/tsunami/').text();52const $ = cheerio.load(html);53const results = [];54$('div.row > div > table.table > tbody > tr').each(function () {55const el = $(this).find('td');56const date = el.eq(0).text().trim();57const locate = el.eq(1).text().trim();58const magnitude = el.eq(2).text().trim();59const depth = el.eq(3).text().trim();60const location = el.eq(4).text().trim();61results.push({62date,63locate,64magnitude,65depth,66location67});68});69return results;70}71//# sourceMappingURL=BMKG.js.map7273