Showing
1 changed file
with
77 additions
and
0 deletions
crawling_broadcasting.js
0 → 100644
1 | +var async = require('async'); | ||
2 | +var webdriver = require('selenium-webdriver'); | ||
3 | +var options = {desiredCapabilities: {browserName: 'chrome'}}; | ||
4 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
5 | +const screen = { | ||
6 | + width: 640, | ||
7 | + height: 480 | ||
8 | +}; | ||
9 | +var a=0 | ||
10 | +var breaktheloop = false | ||
11 | +var driver = new webdriver.Builder(). | ||
12 | + withCapabilities(webdriver.Capabilities.chrome()). | ||
13 | + build(); | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + let url = 'https://people.search.naver.com/search.naver?where=nexearch&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&sm=tab_etc&ie=utf8&key=PeopleService&os=94702'; | ||
18 | + driver | ||
19 | + .get(url) | ||
20 | + .then(() => { | ||
21 | + driver.findElement(webdriver.By.id('pagination_76')) | ||
22 | + .then ( paginationBtn => { | ||
23 | + paginationBtn.findElements(webdriver.By.className('bt_next')) | ||
24 | + .then(Btn_next => { | ||
25 | + driver.findElement(webdriver.By.id('listUI_76')) | ||
26 | + .then(contentsUI => { | ||
27 | + contentsUI.findElements(webdriver.By.tagName('li')) | ||
28 | + .then(elems => { | ||
29 | + elems.forEach(elem => { | ||
30 | + elem.getText() | ||
31 | + .then(text => { | ||
32 | + console.log(text) | ||
33 | + }) | ||
34 | + }) | ||
35 | + }) | ||
36 | + clickandget() | ||
37 | + function clickandget() { | ||
38 | + Btn_next[0].isDisplayed().then(function(state) { | ||
39 | + if(state) { | ||
40 | + Btn_next[0].click() | ||
41 | + sleep(500).then(()=> { | ||
42 | + contentsUI.findElements(webdriver.By.tagName('li')) | ||
43 | + .then(elems => { | ||
44 | + elems.forEach(elem => { | ||
45 | + elem.getText() | ||
46 | + .then(text => { | ||
47 | + console.log(text) | ||
48 | + }) | ||
49 | + }) | ||
50 | + }) | ||
51 | + }) | ||
52 | + } | ||
53 | + else { | ||
54 | + console.log(state) | ||
55 | + } | ||
56 | + }) | ||
57 | + } | ||
58 | + }) | ||
59 | + }) | ||
60 | + }) | ||
61 | + }) | ||
62 | + | ||
63 | + function getContentsandClickNext(callback) { | ||
64 | + driver.findElement(webdriver.By.id('listUI_76')) | ||
65 | + .then(contentsUI => { | ||
66 | + contentsUI.findElements(webdriver.By.tagName('li')) | ||
67 | + .then(elems => { | ||
68 | + elems.forEach(elem => { | ||
69 | + elem.getTex | ||
70 | + }) | ||
71 | + }) | ||
72 | + }) | ||
73 | + } | ||
74 | + | ||
75 | + function sleep (time) { | ||
76 | + return new Promise((resolve) => setTimeout(resolve, time)); | ||
77 | + } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment