Toggle navigation
Toggle navigation
This project
Loading...
Sign in
HyeonJun Jeon
/
Extended-Calendar
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박시진
2022-06-06 02:39:30 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
670d4904ca4068aa9a7d089abff7584e212b4159
670d4904
1 parent
bfdf8fdc
[Add]Close function [Modify]global object complete
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
server/libs/E_Campus.js
server/libs/E_Campus.js
View file @
670d490
...
...
@@ -16,7 +16,7 @@ function setTimeoutPromise(ms) {
async
function
login
(
id
,
pw
)
{
try
{
//for visibility, headless: false
const
browser
=
await
puppeteer
.
launch
({
browser
=
await
puppeteer
.
launch
({
headless
:
false
,
args
:
[
"--window-size=1920x1080"
,
...
...
@@ -63,10 +63,11 @@ async function login(id, pw) {
Info
.
pw
=
pw
;
})
await
page
.
goto
(
"https://khcanvas.khu.ac.kr/"
);
page
=
await
getPeed
(
page
);
await
getSubjects
(
page
);
await
browser
.
close
();
return
Info
;
// let currentPage = await getPeed(page);
// await getSubjects(currentPage);
// await browser.close();
// return Info;
return
page
;
}
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
@@ -110,6 +111,8 @@ async function getPeed(page) {
}
async
function
getSubjects
(
page
)
{
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
(
"#global_nav_courses_link > div.menu-item-icon-container > svg"
);
...
...
@@ -122,10 +125,6 @@ async function getSubjects(page) {
for
(
let
index
=
0
;
index
<
number
;
index
++
)
{
data
.
push
(
await
getOne
(
page
,
index
+
1
));
}
// const promise1 = Promise.resolve(data);
// promise1.then(value => {
// Info.data = value;
// })
const
promise3
=
Promise
.
resolve
(
data
);
promise3
.
then
(
value
=>
{
Info
.
subjects
=
value
;
...
...
@@ -151,6 +150,9 @@ async function getOne(page, index) {
return
Promise
.
resolve
(
data
);
}
async
function
close
()
{
browser
.
close
();
}
// function that contact E_Campus
// if your account is correct, value = Promise {
// { name: '캘린더 피드를 보려면 클릭하세요.',
...
...
@@ -166,13 +168,13 @@ exports.login = login;
//console test
// async function runrun() {
// page = await login("lorem", "lorem");
// await getPeed(page);
// await getSubjects(page);
// console.log(Info);
// }
// runrun();
async
function
runrun
()
{
page
=
await
login
(
"2021105253"
,
"lorem"
);
await
getPeed
(
page
);
await
getSubjects
(
page
);
await
close
();
console
.
log
(
Info
);
}
runrun
();
...
...
Please
register
or
login
to post a comment