Created
January 2, 2023 07:16
-
-
Save tnraro/01b3380037cf1574d9b914a857d05ba9 to your computer and use it in GitHub Desktop.
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
// https://www.weather.go.kr/w/obs-climate/land/past-obs/obs-by-day.do?stn=143 | |
{ | |
const year = document.querySelector("[name=yy]").value; | |
const month = Number(document.querySelector("[name=mm]").value); | |
const startDay = 10; | |
const endDay = 19; | |
const d = new Date(year, month-1, 1); | |
const offset = d.getDay(); | |
const p = x => { | |
const o = {}; | |
for (const m of x.matchAll(/(평균|최고|최저)기온:(-?\d+\.\d+)(?=℃)/g)) { | |
o[m[1]] = Number(m[2]); | |
} | |
return o; | |
}; | |
`${year}\t${month}\t` + [...document.querySelectorAll(".table-cal tr:nth-child(2n)>td")].slice(offset).slice(startDay-1, endDay).filter(x => x.textContent.trim().length !== 0).map(x => p(x.outerText)).map((x, i) => `${x["평균"]}\t${x["최고"]}\t${x["최저"]}`).join("\t"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment