김승훈

add crawling_samename_person

1 +var async = require('async');
2 +var webdriver = require('selenium-webdriver');
3 +var options = {desiredCapabilities: {browserName: 'chrome'}};
4 +var JASON = require('jason')
5 +const {Builder, By, Key, until} = require('selenium-webdriver');
6 +
7 +var ajason = new Object()
8 +var aname = []
9 +var asrc=[]
10 +var alink=[]
11 +var driver = new webdriver.Builder().
12 +withCapabilities(webdriver.Capabilities.chrome()).
13 +build();
14 +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"
15 +driver
16 +.get(url1).then(() => {
17 + driver
18 + .findElements(webdriver.By.className('result_profile'))
19 + .then(whoclasses=> {
20 + whoclasses.forEach(whoclass => {
21 + whoclass.findElements(webdriver.By.className('thmb'))
22 + .then(img_thmbs => {
23 + img_thmbs.forEach(img_thmb => {
24 + img_thmb.findElements(webdriver.By.className('thmb_img')).then(img_src => {
25 +
26 + img_src[0].getAttribute("src")
27 + .then(src => {
28 + if(src) {
29 + asrc.push(src)
30 + }
31 + else {
32 + asrc.push("none")
33 + }
34 + }).then(() => {
35 +
36 + console.log(asrc,alink,aname)
37 + })
38 +
39 +
40 + })
41 + })
42 +
43 + whoclass.findElements(webdriver.By.tagName("strong"))
44 + .then(name_temp => {
45 + name_temp[0].getText().then(name => {
46 + aname.push(name)
47 + })
48 + })
49 + })
50 + whoclass.findElements(webdriver.By.className('who'))
51 + .then(who => {
52 + who[0].findElements(webdriver.By.className('name'))
53 + .then(findname => {
54 + findname[0].getAttribute("href")
55 + .then(link => {
56 + alink.push(link)
57 + })
58 + })
59 + })
60 + })
61 +
62 + })
63 +})
...\ No newline at end of file ...\ No newline at end of file