last_detail.js
3.53 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var async = require('async');
var webdriver = require('selenium-webdriver');
//var options = {desiredCapabilities: {browserName: 'chrome'}};
var chrome = require('selenium-webdriver/chrome')
var Options = new chrome.Options();
Options.addArguments('headless')
Options.addArguments('disable-gpu')
const fs = require('fs')
const test3 = require('./crawling_br_onair_date')
const test4 = require('./crawling_time')
var util = require('util')
var EventEmitter = require('events').EventEmitter;
br_datalist = []
var driver_2 = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome()).setChromeOptions(Options)
.build();
var returnfunction = function() {
var self= this
this.on('ok1',function() {
return br_datalist
})
}
var driver_3 = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome()).setChromeOptions(Options)
.build();
//module.exports = {
var search_detail_time = function (name) {
var self = this
this.on('ok',function() {
if(br_datalist[1] == "방영중") {
if(fs.existsSync("./log/"+name+"_time_detail.txt")) {
const detail = fs.readFileSync("./log/"+name+"_time_detail.txt");
detail_time_list = detail.toString().split(',');
br_datalist.push(detail_time_list[0])
br_datalist.push(detail_time_list[1])
br_datalist.push(detail_time_list[2])
}
else {
test4.search_broadcasting_time(driver_3,br_datalist[0],br_datalist[3],name,function(){
const detail = fs.readFileSync("./log/"+name+"_time_detail.txt");
detail_time_list = detail.toString().split(',');
br_datalist.push(detail_time_list[0])
br_datalist.push(detail_time_list[1])
br_datalist.push(detail_time_list[2])
})
}
}
})
}
//}
util.inherits(returnfunction,EventEmitter);
util.inherits(search_detail_time,EventEmitter);
return_ = new returnfunction();
var detail_time_list = []
//isonair('https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=%EB%9F%B0%EB%8B%9D%EB%A7%A8&oquery=%EB%9F%B0%EB%8B%9D%EB%A7%A8&tqi=UtvQ%2FlpySDVssa%2BpmFNssssstfG-043752',"런닝맨")
module.exports = {
isonair : function (url,string) {
search_detail = new search_detail_time(string)
return new Promise(function(resolve,reject) {
if(fs.existsSync("./log/"+string+"_br_isonair.txt")) {
const img_src_br = fs.readFileSync("./log/"+string+"_br_isonair.txt");
br_datalist = img_src_br.toString().split(',');
search_detail.emit('ok')
setTimeout(() => {
resolve(br_datalist)
}, 5000);
}
else {
test3.search_onairanddate(driver_2,url,string,function() {
const img_src_br = fs.readFileSync("./log/"+string+"_br_isonair.txt");
br_datalist = img_src_br.toString().split(',');
search_detail.emit('ok')
setTimeout(() => {
resolve(br_datalist)
}, 5000);
})
}
})
}
}