diff --git a/index.js b/index.js index 7c03c10..86efaa0 100644 --- a/index.js +++ b/index.js @@ -157,40 +157,36 @@ async function main() { const baseUrl = 'https://nice.kegorii.workers.dev/get?t='; const firstArray = ['S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; for (let i = 0; i < firstArray.length; i++) { - let secondArray = []; - if (i >= 0 && i <= 9) { - secondArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - for (let x = 0; x < secondArray.length; x++) { - for (let y = 0; y < 1000; y++) { - const rtnval = y.toString().padStart(3, '0'); - const kiscode = firstArray[i] + secondArray[x] + rtnval; - const url = `${baseUrl}${kiscode}`; - try { - const startTime = Date.now(); // 시작 시간 저장 + for (let y = 0; y < 10000; y++) { + const rtnval = y.toString().padStart(4, '0'); + const kiscode = firstArray[i] + rtnval; + const url = `${baseUrl}${kiscode}`; + try { + const startTime = Date.now(); // 시작 시간 저장 - const response = await fetch(url); + const response = await fetch(url); - if (!response.ok) { - throw new Error(`Request failed: ${response.statusText}`); - } - - const jsonData = await response.json(); - const insertValues = jsonData.map(item => ({ - ...item // 모든 데이터를 그대로 삽입 (데이터 정제 필요) - })); - - if (insertValues.length > 0) { - await orm.insert(niceTable).values(insertValues); - } - - const endTime = Date.now(); // 종료 시간 저장 - console.log(`Execution time for kiscode:${kiscode}: ${endTime - startTime} ms`); // 콘솔에 시간 출력 - } catch (error) { - console.error(`Error at kiscode:${kiscode}`, error); - } + if (!response.ok) { + throw new Error(`Request failed: ${response.statusText}`); } + + const jsonData = await response.json(); + const insertValues = jsonData.map(item => ({ + ...item // 모든 데이터를 그대로 삽입 (데이터 정제 필요) + })); + + if (insertValues.length > 0) { + await orm.insert(niceTable).values(insertValues); + } + + const endTime = Date.now(); // 종료 시간 저장 + console.log(`Execution time for kiscode:${kiscode}: ${endTime - startTime} ms`); // 콘솔에 시간 출력 + } catch (error) { + console.error(`Error at kiscode:${kiscode}`, error); } } } - main(); \ No newline at end of file +} + +main(); \ No newline at end of file