Created
March 16, 2021 16:37
-
-
Save hrafnkelle/87ae0d0b9c646360af7ac35d38fd809d to your computer and use it in GitHub Desktop.
Retreive and print quake date and size from the Icelandic Met office
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run with node: | |
// node getQuakes.js 3.5 | |
// to get all quakes over M3.5 | |
async function getQuakesFromMetoffice(minimumQuakeSize) { | |
const axios = require('axios'); | |
let pageHtml = await axios.get('https://vedur.is/skjalftar-og-eldgos/jardskjalftar/reykjanesskagi/#view=table'); | |
lines = pageHtml.data.split('\r\n'); | |
let VI = {quakeInfo: undefined}; | |
eval(lines.filter(l=>/VI.quakeInfo/.test(l))[0]); | |
return VI.quakeInfo.map(x=>{ return {...x, s: parseFloat(x.s.replace(',','.'))} }).filter(x=> x.s>=minimumQuakeSize); | |
}; | |
(async function() { | |
const minimumQuakeSize = parseFloat(process.argv[2]?process.argv[2]:3.0); | |
const quakes = await getQuakesFromMetoffice(minimumQuakeSize); | |
quakes.sort((a,b)=>a>b?1:-1).forEach(x=>console.log(x.t, x.s)); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment