박시진

[Modify]Info.subjects's type => list (to extract name of subjects)

......@@ -4,7 +4,7 @@ Info = {
id : "null",
pw : "null",
peed : "null",
subjects : {}
subjects : []
}
function setTimeoutPromise(ms) {
......@@ -63,10 +63,6 @@ async function login(id, pw) {
Info.pw = pw;
})
await page.goto("https://khcanvas.khu.ac.kr/");
// let currentPage = await getPeed(page);
// await getSubjects(currentPage);
// await browser.close();
// return Info;
return page;
}
} catch (err) {
......@@ -111,6 +107,7 @@ async function getPeed(page) {
}
async function getSubjects(page) {
//close the peed window to get subjects
await page.click('body > div:nth-child(9) > div.ui-dialog-titlebar.ui-widget-header.ui-corner-all.ui-helper-clearfix > button > span');
await page.waitForTimeout(500);
await page.click(
......@@ -127,7 +124,10 @@ async function getSubjects(page) {
}
const promise3 = Promise.resolve(data);
promise3.then(value => {
Info.subjects = value;
// Info.subjects = value;
for (let index = 0; index < value.length; index++) {
Info.subjects.push(value[index].name)
}
})
return data;
}
......@@ -153,18 +153,12 @@ async function getOne(page, index) {
async function close() {
browser.close();
}
// function that contact E_Campus
// if your account is correct, value = Promise {
// { name: '캘린더 피드를 보려면 클릭하세요.',
// link: 'https://khcanvas.khu.ac.kr/feeds/calendars/user_~~~.ics'
// }
//}
// if your account is incorrect, value = [ '', '', 'Incorrect user ID or password.' ]
exports.login = login;
// exports.getPeed = getPeed;
// exports.getSubjects = getSubjects;
exports.login = login;
exports.getPeed = getPeed;
exports.getSubjects = getSubjects;
exports.close = close;
//console test
......@@ -174,6 +168,7 @@ async function runrun() {
await getSubjects(page);
await close();
console.log(Info);
console.log(Info.subjects)
}
runrun();
......