박시진

[Modifiy]Data input is possible

......@@ -3,29 +3,26 @@ function login(id, pw) {
const crawler = async() => {
try{
const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']});
// for observing the process of login, headless -> false
const page = await browser.newPage();
await page.setViewport({
width:1920,
height:1080
})
await page.goto('https://e-campus.khu.ac.kr/xn-sso/login.php?auto_login=&sso_only=&cvs_lgn=&return_url=https%3A%2F%2Fe-campus.khu.ac.kr%2Fxn-sso%2Fgw-cb.php%3Ffrom%3D%26login_type%3Dstandalone%26return_url%3Dhttps%253A%252F%252Fe-campus.khu.ac.kr%252Flogin%252Fcallback');
await page.evaluate(() => {
document.querySelector("#login_user_id").value = id
document.querySelector("#login_user_password").value = pw
document.querySelector('#form1 > div > div.login_btn > a > span').click();
})
await page.waitForTimeout(500);
}catch(err){
console.log(err)
await page.type("#login_user_id", id);
await page.type("#login_user_password", pw);
await page.click('#form1 > div > div.login_btn > a > span');
if(page.url() === 'https://e-campus.khu.ac.kr/xn-sso/gw-cb.php?from=&login_type=standalone&return_url=https%3A%2F%2Fe-campus.khu.ac.kr%2Flogin%2Fcallback'){
return "Incorrect user ID or password."
}
if(page.url() === 'https://e-campus.khu.ac.kr/xn-sso/login.php?auto_login=&sso_only=&cvs_lgn=&return_url=https%3A%2F%2Fe-campus.khu.ac.kr%2Fxn-sso%2Fgw-cb.php%3Ffrom%3D%26login_type%3Dstandalone%26return_url%3Dhttps%253A%252F%252Fe-campus.khu.ac.kr%252Flogin%252Fcallback'){
return "the account id or password you entered is incorrect";}
else {
return `I got data { id:"${id}" pw:"${pw}" }`;
}
}catch(err){
console.log(err)
}
}
crawler();
}
......