최재은

Login crawling test success using puppeteer

1 +const puppeteer = require('puppeteer');
2 +(async () => {
3 + const browser = await puppeteer.launch();
4 + const page = await browser.newPage();
5 + const et_id = "";
6 + const et_pw = "";
7 + const lecture = "오픈소스SW개발";
8 + await page.goto('https://everytime.kr/login');
9 + await page.evaluate((id, pw) => {
10 + document.querySelector("input[name=userid]").value = id;
11 + document.querySelector("input[name=password]").value = pw;
12 + }, et_id, et_pw);
13 + await console.log("로그인 정보 삽입 완료")
14 + await page.click('#container > form > p.submit > input');
15 + await page.waitFor(1000);
16 + await page.goto('https://everytime.kr/lecture');
17 + await page.screenshot({ path: 'AfterLogin.png', fullPage:true });
18 + await page.evaluate((lec) => {
19 + document.querySelector("input[name=keyword]").value = lec;
20 + }, lecture);
21 + await page.click('#container > form > input.submit');
22 + await page.waitFor(1000);
23 + await page.click('#container > div > a')
24 + await page.waitFor(1000);
25 + await page.screenshot({ path: 'result.png', fullPage:true });
26 + await browser.close();
27 +})();
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
14 "dotenv": "^8.0.0", 14 "dotenv": "^8.0.0",
15 "express": "^4.17.0", 15 "express": "^4.17.0",
16 "mongoose": "^5.5.11", 16 "mongoose": "^5.5.11",
17 + "puppeteer": "^1.17.0",
18 + "puppeteer-core": "^1.17.0",
17 "request": "^2.88.0" 19 "request": "^2.88.0"
18 } 20 }
19 } 21 }
......