Showing
3 changed files
with
64 additions
and
27 deletions
AfterLogin.png
0 → 100644
146 KB
crawling_test.js
deleted
100644 → 0
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 |
everytime_crawling.js
0 → 100644
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 = ""; | ||
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.evaluate((lec) => { | ||
18 | + document.querySelector("input[name=keyword]").value = lec; | ||
19 | + }, lecture); | ||
20 | + await page.click('#container > form > input.submit'); | ||
21 | + await page.waitFor(1000); | ||
22 | + | ||
23 | + let tempclass = await page.evaluate((sel) => { | ||
24 | + return Array.from(document.getElementsByClassName(sel)).map(node => node.href); | ||
25 | + }, 'lecture'); | ||
26 | + console.log(tempclass) | ||
27 | + | ||
28 | + | ||
29 | + for (var i in tempclass) { | ||
30 | + console.log(tempclass[i]); | ||
31 | + await page.goto(tempclass[i]); | ||
32 | + await page.waitFor(1000); | ||
33 | + await page.waitForSelector('#container > div.side.head > h2'); | ||
34 | + const lecturename = await page.evaluate(() => { | ||
35 | + const anchors1 = Array.from(document.querySelectorAll('#container > div.side.head > h2')); | ||
36 | + return anchors1.map(anchor1 => anchor1.textContent); | ||
37 | + }); | ||
38 | + await page.waitForSelector('#container > div.side.head > p:nth-child(3) > span'); | ||
39 | + const proname = await page.evaluate(() => { | ||
40 | + const anchors2 = Array.from(document.querySelectorAll('#container > div.side.head > p:nth-child(3) > span')); | ||
41 | + return anchors2.map(anchor2 => anchor2.textContent); | ||
42 | + }); | ||
43 | + await page.waitForSelector('#container > div.side.article > div.rating > div.rate > span > span.value'); | ||
44 | + const avg_rate = await page.evaluate(() => { | ||
45 | + const anchors3 = Array.from(document.querySelectorAll('#container > div.side.article > div.rating > div.rate > span > span.value')); | ||
46 | + return anchors3.map(anchor3 => anchor3.textContent); | ||
47 | + }); | ||
48 | + let review = []; | ||
49 | + if (await page.$('#container > div.side.article > div.articles > article > p.text') !== null){ | ||
50 | + await page.waitForSelector('#container > div.side.article > div.articles > article > p.text'); | ||
51 | + review = await page.evaluate(() => { | ||
52 | + const anchors4 = Array.from(document.querySelectorAll('#container > div.side.article > div.articles > article > p.text')); | ||
53 | + return anchors4.map(anchor4 => anchor4.textContent); | ||
54 | + }); | ||
55 | + } | ||
56 | + //콘솔에 출력한다. | ||
57 | + console.log(lecturename.join('\n')); | ||
58 | + console.log(proname.join('\n')); | ||
59 | + console.log(avg_rate.join('\n')); | ||
60 | + console.log(review); | ||
61 | + } | ||
62 | + | ||
63 | + await browser.close(); | ||
64 | +})(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment