crawling_samename.js
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var async = require('async');
var webdriver = require('selenium-webdriver');
var options = {desiredCapabilities: {browserName: 'chrome'}};
var JASON = require('jason')
const {Builder, By, Key, until} = require('selenium-webdriver');
var ajason = new Object()
var aname = []
var asrc=[]
var alink=[]
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let url1 = "https://people.search.naver.com/search.naver?sm=sbx_hty&where=nexearch&ie=utf8&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&x=0&y=0"
driver
.get(url1).then(() => {
driver
.findElements(webdriver.By.className('result_profile'))
.then(whoclasses=> {
whoclasses.forEach(whoclass => {
whoclass.findElements(webdriver.By.className('thmb'))
.then(img_thmbs => {
img_thmbs.forEach(img_thmb => {
img_thmb.findElements(webdriver.By.className('thmb_img')).then(img_src => {
img_src[0].getAttribute("src")
.then(src => {
if(src) {
asrc.push(src)
}
else {
asrc.push("none")
}
}).then(() => {
console.log(asrc,alink,aname)
})
})
})
whoclass.findElements(webdriver.By.tagName("strong"))
.then(name_temp => {
name_temp[0].getText().then(name => {
aname.push(name)
})
})
})
whoclass.findElements(webdriver.By.className('who'))
.then(who => {
who[0].findElements(webdriver.By.className('name'))
.then(findname => {
findname[0].getAttribute("href")
.then(link => {
alink.push(link)
})
})
})
})
})
})