Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save f2janyway/0eb3c61352ab04d4d192097621fddccb to your computer and use it in GitHub Desktop.

Select an option

Save f2janyway/0eb3c61352ab04d4d192097621fddccb to your computer and use it in GitHub Desktop.
홈택스에서 안해주니까...

http://data.krx.co.kr/contents/MDC/MAIN/main/index.cmd

위의 사이트에서

해당주식검색 > 일자별 시세 > 해당 기간(조회 설정후) 설정 > 개발자모드 콘솔 > 종가 평균값계산 (아래)코드 복붙

var cnt = 0
var sum = 0
document.querySelectorAll('td').forEach((i) => {
    if (i.getAttribute('data-name') == 'TDD_CLSPRC') {
        if (cnt == 0) {
            //title
            cnt += 1
            return
        }
        let numStr = i.innerText.replaceAll(",", "")
        let num = Number(numStr)
        console.log(cnt, num)
        sum += num
        cnt += 1
    }
})
cnt -= 1
let rs = sum / cnt
console.log("AVG:", rs, "sum", sum, "cnt", cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment