Showing
1 changed file
with
19 additions
and
17 deletions
... | @@ -16,7 +16,7 @@ function setTimeoutPromise(ms) { | ... | @@ -16,7 +16,7 @@ function setTimeoutPromise(ms) { |
16 | async function login(id, pw) { | 16 | async function login(id, pw) { |
17 | try { | 17 | try { |
18 | //for visibility, headless: false | 18 | //for visibility, headless: false |
19 | - const browser = await puppeteer.launch({ | 19 | + browser = await puppeteer.launch({ |
20 | headless: false, | 20 | headless: false, |
21 | args: [ | 21 | args: [ |
22 | "--window-size=1920x1080", | 22 | "--window-size=1920x1080", |
... | @@ -63,10 +63,11 @@ async function login(id, pw) { | ... | @@ -63,10 +63,11 @@ async function login(id, pw) { |
63 | Info.pw = pw; | 63 | Info.pw = pw; |
64 | }) | 64 | }) |
65 | await page.goto("https://khcanvas.khu.ac.kr/"); | 65 | await page.goto("https://khcanvas.khu.ac.kr/"); |
66 | - page = await getPeed(page); | 66 | + // let currentPage = await getPeed(page); |
67 | - await getSubjects(page); | 67 | + // await getSubjects(currentPage); |
68 | - await browser.close(); | 68 | + // await browser.close(); |
69 | - return Info; | 69 | + // return Info; |
70 | + return page; | ||
70 | } | 71 | } |
71 | } catch (err) { | 72 | } catch (err) { |
72 | console.log(err); | 73 | console.log(err); |
... | @@ -110,6 +111,8 @@ async function getPeed(page) { | ... | @@ -110,6 +111,8 @@ async function getPeed(page) { |
110 | } | 111 | } |
111 | 112 | ||
112 | async function getSubjects(page) { | 113 | async function getSubjects(page) { |
114 | + await page.click('body > div:nth-child(9) > div.ui-dialog-titlebar.ui-widget-header.ui-corner-all.ui-helper-clearfix > button > span'); | ||
115 | + await page.waitForTimeout(500); | ||
113 | await page.click( | 116 | await page.click( |
114 | "#global_nav_courses_link > div.menu-item-icon-container > svg" | 117 | "#global_nav_courses_link > div.menu-item-icon-container > svg" |
115 | ); | 118 | ); |
... | @@ -122,10 +125,6 @@ async function getSubjects(page) { | ... | @@ -122,10 +125,6 @@ async function getSubjects(page) { |
122 | for (let index = 0; index < number; index++) { | 125 | for (let index = 0; index < number; index++) { |
123 | data.push(await getOne(page, index + 1)); | 126 | data.push(await getOne(page, index + 1)); |
124 | } | 127 | } |
125 | - // const promise1 = Promise.resolve(data); | ||
126 | - // promise1.then(value => { | ||
127 | - // Info.data = value; | ||
128 | - // }) | ||
129 | const promise3 = Promise.resolve(data); | 128 | const promise3 = Promise.resolve(data); |
130 | promise3.then(value => { | 129 | promise3.then(value => { |
131 | Info.subjects = value; | 130 | Info.subjects = value; |
... | @@ -151,6 +150,9 @@ async function getOne(page, index) { | ... | @@ -151,6 +150,9 @@ async function getOne(page, index) { |
151 | return Promise.resolve(data); | 150 | return Promise.resolve(data); |
152 | } | 151 | } |
153 | 152 | ||
153 | +async function close() { | ||
154 | + browser.close(); | ||
155 | +} | ||
154 | // function that contact E_Campus | 156 | // function that contact E_Campus |
155 | // if your account is correct, value = Promise { | 157 | // if your account is correct, value = Promise { |
156 | // { name: '캘린더 피드를 보려면 클릭하세요.', | 158 | // { name: '캘린더 피드를 보려면 클릭하세요.', |
... | @@ -166,13 +168,13 @@ exports.login = login; | ... | @@ -166,13 +168,13 @@ exports.login = login; |
166 | 168 | ||
167 | 169 | ||
168 | //console test | 170 | //console test |
169 | -// async function runrun() { | 171 | +async function runrun() { |
170 | -// page = await login("lorem", "lorem"); | 172 | + page = await login("2021105253", "lorem"); |
171 | -// await getPeed(page); | 173 | + await getPeed(page); |
172 | -// await getSubjects(page); | 174 | + await getSubjects(page); |
173 | -// console.log(Info); | 175 | + await close(); |
174 | - | 176 | + console.log(Info); |
175 | -// } | ||
176 | -// runrun(); | ||
177 | 177 | ||
178 | +} | ||
179 | +runrun(); | ||
178 | 180 | ... | ... |
-
Please register or login to post a comment