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
HyeonJun Jeon
2022-06-03 01:14:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72386e9cdd7c797d16b66aaa9659cecf29334c0d
72386e9c
1 parent
76aba681
[Fix] Enable headless mode
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
server/libs/E_Campus.js
server/routers/login.js
src/pages/Debug.js
server/libs/E_Campus.js
View file @
72386e9
...
...
@@ -11,8 +11,14 @@ async function login(id, pw) {
try
{
//for visibility, headless: false
const
browser
=
await
puppeteer
.
launch
({
headless
:
false
,
args
:
[
"--window-size=1920,1080"
],
headless
:
true
,
args
:
[
"--window-size=1920x1080"
,
"--start-maximized"
,
"--no-sandbox"
,
"--disable-dev-shm-usage"
,
"--lang=ko"
,
],
});
const
page
=
await
browser
.
newPage
();
...
...
@@ -40,11 +46,12 @@ async function login(id, pw) {
return
false
;
}
else
{
// 내 강의실
let
selector
=
"#visual > div > div.xn-main-login-container > div:nth-child(2) > div.xn-main-link-wrap.xn-main-lms-link-wrap > a"
;
await
page
.
waitForSelector
(
selector
);
await
Promise
.
all
([
page
.
click
(
selector
),
page
.
waitForNavigation
()]);
// let selector =
// "#visual > div > div.xn-main-login-container > div:nth-child(2) > div.xn-main-link-wrap.xn-main-lms-link-wrap > a";
// await page.waitForSelector(selector);
// await Promise.all([page.click(selector), page.waitForNavigation()]);
await
page
.
goto
(
"https://khcanvas.khu.ac.kr/"
);
return
page
;
}
}
catch
(
err
)
{
...
...
@@ -55,7 +62,7 @@ async function login(id, pw) {
//function that get your peed for your Ecampus calendar
async
function
getPeed
(
page
)
{
selector
=
"#global_nav_calendar_link > div.menu-item-icon-container > svg"
;
await
page
.
waitForSelector
(
selector
);
await
page
.
waitForSelector
(
selector
,
{
timeout
:
1000
}
);
await
Promise
.
all
([
page
.
click
(
selector
),
page
.
waitForNavigation
()]);
selector
=
"#calendar-feed > button"
;
...
...
server/routers/login.js
View file @
72386e9
...
...
@@ -7,9 +7,14 @@ router.post("/", async (req, res) => {
console
.
log
(
`listened /login
${
req
.
body
.
id
}
${
req
.
body
.
pw
}
`
);
const
page
=
await
login
(
req
.
body
.
id
,
req
.
body
.
pw
);
if
(
page
)
{
const
peed
=
await
getPeed
(
page
);
res
.
send
(
peed
);
}
else
res
.
send
(
"failed"
);
try
{
const
peed
=
await
getPeed
(
page
);
res
.
send
(
peed
);
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
send
(
"error"
);
}
}
else
res
.
send
(
"login failed"
);
});
module
.
exports
=
router
;
...
...
src/pages/Debug.js
View file @
72386e9
...
...
@@ -34,6 +34,7 @@ const Debug = () => {
//result = login(state.input1, state.input2);
break
;
case
"server"
:
setState
({
...
state
,
output
:
"loading..."
});
axios
.
post
(
"http://localhost:3001/login/"
,
{
id
:
state
.
input1
,
...
...
Please
register
or
login
to post a comment