|
2026-05-16 10:49
조회: 221
추천: 0
과금량 참고계정정보 - 구매 사용내역 - 검사 한국 - F12 후 복붙 ![]() 위와 같은 오류가 뜨면 콘솔창에 allow pasting을 입력 후 엔터치고 F5 누른후에 재시도 let startYear = 2014; let endYear = 2026; let total = 0; const today = new Date(); const todayYear = today.getFullYear(); const todayMonth = String(today.getMonth() + 1).padStart(2, '0'); const todayDate = String(today.getDate()).padStart(2, '0'); const endDateFormatted = `${todayYear}.${todayMonth}.${todayDate}`; async function fetchAmountsForYear(year) { let yearTotal = 0; let page = 1; let hasNextPage = true; while (hasNextPage) { const startDate = `${year}.01.01`; const endDate = year === todayYear ? endDateFormatted : `${year}.12.31`; const baseUrl = `?startDate=${startDate}&endDate=${endDate}&Page=${page}`; const response = await fetch(baseUrl); const text = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(text, 'text/html'); var emptyMessageCell = doc.querySelector('td.empty'); if (emptyMessageCell && emptyMessageCell.textContent.trim() === '해당이력이 없습니다.') { console.log(`년도 ${year}에 해당 이력이 없습니다. 다음 년도로 진행합니다.`); return null; } const amounts = doc.querySelectorAll('td.amount'); amounts.forEach(amount => { const value = parseInt(amount.textContent.replace(/,/g, ''), 11); if (value > 0) { yearTotal += value; } }); const nextButton = doc.querySelector('a.btn_arrow.next'); hasNextPage = nextButton !== null; page++; } return yearTotal; } async function fetchAllAmounts() { for (let year = startYear; year <= endYear; year++) { const yearTotal = await fetchAmountsForYear(year); if (yearTotal !== null) { total += yearTotal; const formattedYearTotal = yearTotal.toString().replace(/B(?=(d{3})+(?!d))/g, ","); console.log(`${year}년의 총 금액: ${formattedYearTotal}원`); } } const formattedTotal = total.toString().replace(/B(?=(d{3})+(?!d))/g, ","); console.log("지금까지 사용한 총 금액 :", formattedTotal + "원"); } fetchAllAmounts();
EXP
3,713
(28%)
/ 4,001
![]()
|

나무할배 