[Modify]Info.subjects's type => list (to extract name of subjects)
Showing
1 changed file
with
11 additions
and
16 deletions
... | @@ -4,7 +4,7 @@ Info = { | ... | @@ -4,7 +4,7 @@ Info = { |
4 | id : "null", | 4 | id : "null", |
5 | pw : "null", | 5 | pw : "null", |
6 | peed : "null", | 6 | peed : "null", |
7 | - subjects : {} | 7 | + subjects : [] |
8 | } | 8 | } |
9 | 9 | ||
10 | function setTimeoutPromise(ms) { | 10 | function setTimeoutPromise(ms) { |
... | @@ -63,10 +63,6 @@ async function login(id, pw) { | ... | @@ -63,10 +63,6 @@ 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 | - // let currentPage = await getPeed(page); | ||
67 | - // await getSubjects(currentPage); | ||
68 | - // await browser.close(); | ||
69 | - // return Info; | ||
70 | return page; | 66 | return page; |
71 | } | 67 | } |
72 | } catch (err) { | 68 | } catch (err) { |
... | @@ -111,6 +107,7 @@ async function getPeed(page) { | ... | @@ -111,6 +107,7 @@ async function getPeed(page) { |
111 | } | 107 | } |
112 | 108 | ||
113 | async function getSubjects(page) { | 109 | async function getSubjects(page) { |
110 | + //close the peed window to get subjects | ||
114 | await page.click('body > div:nth-child(9) > div.ui-dialog-titlebar.ui-widget-header.ui-corner-all.ui-helper-clearfix > button > span'); | 111 | 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); | 112 | await page.waitForTimeout(500); |
116 | await page.click( | 113 | await page.click( |
... | @@ -127,7 +124,10 @@ async function getSubjects(page) { | ... | @@ -127,7 +124,10 @@ async function getSubjects(page) { |
127 | } | 124 | } |
128 | const promise3 = Promise.resolve(data); | 125 | const promise3 = Promise.resolve(data); |
129 | promise3.then(value => { | 126 | promise3.then(value => { |
130 | - Info.subjects = value; | 127 | + // Info.subjects = value; |
128 | + for (let index = 0; index < value.length; index++) { | ||
129 | + Info.subjects.push(value[index].name) | ||
130 | + } | ||
131 | }) | 131 | }) |
132 | return data; | 132 | return data; |
133 | } | 133 | } |
... | @@ -153,18 +153,12 @@ async function getOne(page, index) { | ... | @@ -153,18 +153,12 @@ async function getOne(page, index) { |
153 | async function close() { | 153 | async function close() { |
154 | browser.close(); | 154 | browser.close(); |
155 | } | 155 | } |
156 | -// function that contact E_Campus | ||
157 | -// if your account is correct, value = Promise { | ||
158 | -// { name: '캘린더 피드를 보려면 클릭하세요.', | ||
159 | -// link: 'https://khcanvas.khu.ac.kr/feeds/calendars/user_~~~.ics' | ||
160 | -// } | ||
161 | -//} | ||
162 | -// if your account is incorrect, value = [ '', '', 'Incorrect user ID or password.' ] | ||
163 | 156 | ||
164 | -exports.login = login; | ||
165 | -// exports.getPeed = getPeed; | ||
166 | -// exports.getSubjects = getSubjects; | ||
167 | 157 | ||
158 | +exports.login = login; | ||
159 | +exports.getPeed = getPeed; | ||
160 | +exports.getSubjects = getSubjects; | ||
161 | +exports.close = close; | ||
168 | 162 | ||
169 | 163 | ||
170 | //console test | 164 | //console test |
... | @@ -174,6 +168,7 @@ async function runrun() { | ... | @@ -174,6 +168,7 @@ async function runrun() { |
174 | await getSubjects(page); | 168 | await getSubjects(page); |
175 | await close(); | 169 | await close(); |
176 | console.log(Info); | 170 | console.log(Info); |
171 | + console.log(Info.subjects) | ||
177 | 172 | ||
178 | } | 173 | } |
179 | runrun(); | 174 | runrun(); | ... | ... |
-
Please register or login to post a comment