crawling_br_onair_date.js
3.33 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
64
65
66
67
68
69
70
71
72
73
74
75
76
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 iconv = require('iconv-lite')
const fs = require('fs')
datalist = []
module.exports = {
search_onairanddate : function (driver, url, string, callback) {
driver
.get(url).then(() => {
driver
.findElements(webdriver.By.className('brcs_detail'))
.then(broad_info => {
broad_info[0].findElement(webdriver.By.tagName('dl'))
.then(more_data => {
more_data.findElement(webdriver.By.tagName('dd'))
.then(one_line => {
one_line.findElement(webdriver.By.className("inline"))
.then(isbroad => {
isbroad.findElement(webdriver.By.tagName("a"))
.then(a => {
a.getText()
.then(text=> {
isbroad.getText()
.then(day => {
isbroad.findElement(webdriver.By.className("broad_txt"))
.then(b => {
b.getText()
.then(text2 => {
if(day.indexOf('(') != -1) {
var day_ = day[day.indexOf('(')+1]
}
datalist.push(text)
datalist.push(text2)
datalist[3] = day_
setTimeout(() => {
fs.writeFileSync("./log/"+string+"_br_isonair.txt", datalist, {encoding: 'utf8'});
callback()
}, 500);
})
})
})
})
})
})
})
})
})
})
driver.findElement(webdriver.By.className('brcs_thumb'))
.then(brcs_thumb => {
brcs_thumb.findElements(webdriver.By.tagName('img'))
.then( img => {
img[0].getAttribute('src')
.then(img_src => {
datalist[2] = img_src
})
})
})
}
}
//
//var driver = new webdriver.Builder()
//.forBrowser('chrome')
//.withCapabilities(webdriver.Capabilities.chrome())
//.build();
//
//search_onairanddate(driver,"https://search.naver.com/search.naver?where=nexearch&sm=ppl_cts&mra=bjkw&x_csa=%7B%22pkid%22%3A%2257%22%2C%22os%22%3A%22659910%22%7D&pkid=57&os=659910&query=%EB%AC%B4%ED%95%9C%EB%8F%84%EC%A0%84","무한도전",function() {
// console.log("B")
//})