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