Showing
14 changed files
with
577 additions
and
0 deletions
selenium-function/crawling_br_onair_date.js
0 → 100644
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 | +var iconv = require('iconv-lite') | ||
7 | +const fs = require('fs') | ||
8 | + | ||
9 | +datalist = [] | ||
10 | + | ||
11 | +module.exports = { | ||
12 | + search_onairanddate: function(driver,string,callback) { | ||
13 | + let url1 = "https://search.naver.com/search.naver?sm=top_hty&fbm=1&ie=utf8&query=" + string | ||
14 | + driver | ||
15 | + .get(url1).then(() => { | ||
16 | + driver | ||
17 | + .findElements(webdriver.By.className('brcs_detail')) | ||
18 | + .then(broad_info => { | ||
19 | + broad_info[0].findElement(webdriver.By.tagName('dl')) | ||
20 | + .then(more_data => { | ||
21 | + more_data.findElement(webdriver.By.tagName('dd')) | ||
22 | + .then(one_line => { | ||
23 | + one_line.findElement(webdriver.By.className("inline")) | ||
24 | + .then(isbroad => { | ||
25 | + isbroad.getText() | ||
26 | + .then(isbroad_string => { | ||
27 | + broadcasting=isbroad_string.substring(0,4) | ||
28 | + isbroad = isbroad_string.substring(18,21) | ||
29 | + br_date = isbroad_string.substring(23,24) | ||
30 | + br_date = br_date + "요일" | ||
31 | + br_time = isbroad_string.substring(26,34) | ||
32 | + datalist.push(broadcasting,isbroad,br_date,br_time) | ||
33 | + | ||
34 | + fs.writeFileSync("./log/"+string+"_br_isonair.txt", '\ufeff' + datalist, {encoding: 'utf8'}); | ||
35 | + for(var i =0; i<100; ) { | ||
36 | + | ||
37 | + if() { | ||
38 | + i++ | ||
39 | + } | ||
40 | + } | ||
41 | + callback() | ||
42 | + }) | ||
43 | + }) | ||
44 | + }) | ||
45 | + }) | ||
46 | + }) | ||
47 | + }) | ||
48 | + driver.findElement(webdriver.By.className('brcs_thumb')) | ||
49 | + .then(brcs_thumb => { | ||
50 | + brcs_thumb.findElements(webdriver.By.tagName('img')) | ||
51 | + .then( img => { | ||
52 | + img[0].getAttribute('src') | ||
53 | + .then(img_src => { | ||
54 | + datalist.push(img_src) | ||
55 | + }) | ||
56 | + }) | ||
57 | + }) | ||
58 | + } | ||
59 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/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 fs = require('fs') | ||
6 | +const screen = { | ||
7 | + width: 640, | ||
8 | + height: 480 | ||
9 | +}; | ||
10 | +var a=8000 | ||
11 | +var img_src_list = [] | ||
12 | +var text_list = [] | ||
13 | +var testStartRunTime = 0; | ||
14 | +var testruntime = 0; | ||
15 | +var time = 0; | ||
16 | +module.exports = { | ||
17 | + search_broadcasting :function(driver,url,name,callback) { | ||
18 | + function testRunTimer() { | ||
19 | + var today = new Date(); // 현재시간 얻기 | ||
20 | + var runTime = today.getTime(); // 밀리세컨드 ( 1970/01/01 부터 현재까지의 시간을 밀리세컨드로 나타냄 ) | ||
21 | + var rtn = 0; | ||
22 | + | ||
23 | + if (testStartRunTime == 0) { | ||
24 | + testStartRunTime = runTime; | ||
25 | + } else { | ||
26 | + rtn = (runTime - testStartRunTime) / 1000; | ||
27 | + testStartRunTime = 0; | ||
28 | + } | ||
29 | + return rtn; | ||
30 | + } | ||
31 | + driver | ||
32 | + .get("http://"+url) | ||
33 | + .then(() => { | ||
34 | + driver.findElement(webdriver.By.id('pagination_76')) | ||
35 | + .then ( paginationBtn => { | ||
36 | + paginationBtn.findElements(webdriver.By.className('bt_next')) | ||
37 | + .then(Btn_next => { | ||
38 | + driver.findElement(webdriver.By.id('listUI_76')) | ||
39 | + .then(contentsUI => { | ||
40 | + clickandget(function() { | ||
41 | + Btn_next[0].click() | ||
42 | + setTimeout(() => { | ||
43 | + clickandget(function() { | ||
44 | + Btn_next[0].click() | ||
45 | + setTimeout(() => { | ||
46 | + clickandget(function() { | ||
47 | + Btn_next[0].click() | ||
48 | + setTimeout(() => { | ||
49 | + clickandget(function(){ | ||
50 | + Btn_next[0].click() | ||
51 | + setTimeout(() => { | ||
52 | + clickandget(function(){ | ||
53 | + fs.writeFileSync("./log/"+name+"_img_src_br.txt", '\ufeff' + img_src_list, {encoding: 'utf8'}); | ||
54 | + fs.writeFileSync("./log/"+name+"_title_br.txt", '\ufeff' + text_list, {encoding: 'utf8'}); | ||
55 | + setTimeout(() => { | ||
56 | + callback() | ||
57 | + }, 500); | ||
58 | + }) | ||
59 | + }, testruntime*1000+800); | ||
60 | + }) | ||
61 | + }, testruntime*1000+800); | ||
62 | + | ||
63 | + },testruntime*1000+800) | ||
64 | + }, testruntime*1000+800); | ||
65 | + }) | ||
66 | + }, testruntime*1000+800); | ||
67 | + }) | ||
68 | + function clickandget(_callback) { | ||
69 | + testRunTimer() | ||
70 | + Btn_next[0].isDisplayed().then(function(state) { | ||
71 | + if(state) { | ||
72 | + contentsUI.findElements(webdriver.By.tagName('li')) | ||
73 | + .then(elems => { | ||
74 | + elems.forEach(elem => { | ||
75 | + elem.findElements(webdriver.By.tagName('img')) | ||
76 | + .then(img => { | ||
77 | + img[0].getAttribute('src') | ||
78 | + .then(img_src => { | ||
79 | + elem.findElements(webdriver.By.className('tit')) | ||
80 | + .then (titles => { | ||
81 | + titles.forEach(title => { | ||
82 | + title.getText() | ||
83 | + .then(text => { | ||
84 | + text_list.push(text) | ||
85 | + img_src_list.push(img_src) | ||
86 | + if(text_list.length % 5 == 0) { | ||
87 | + var testruntime = testRunTimer(); | ||
88 | + time = time+testruntime*1000 | ||
89 | + _callback() | ||
90 | + } | ||
91 | + }) | ||
92 | + }) | ||
93 | + }) | ||
94 | + }) | ||
95 | + }) | ||
96 | + }) | ||
97 | + }) | ||
98 | + } | ||
99 | + else { | ||
100 | + fs.writeFileSync("./log/"+name+"_img_src_br.txt", '\ufeff' + img_src_list, {encoding: 'utf8'}); | ||
101 | + fs.writeFileSync("./log/"+name+"_title_br.txt", '\ufeff' + text_list, {encoding: 'utf8'}); | ||
102 | + setTimeout(() => { | ||
103 | + callback() | ||
104 | + }, 500); | ||
105 | + } | ||
106 | + },function(err) { | ||
107 | + fs.writeFileSync("./log/"+name+"_img_src_br.txt", '\ufeff' + img_src_list, {encoding: 'utf8'}); | ||
108 | + fs.writeFileSync("./log/"+name+"_title_br.txt", '\ufeff' + text_list, {encoding: 'utf8'}); | ||
109 | + setTimeout(() => { | ||
110 | + callback() | ||
111 | + }, 500); | ||
112 | + }) | ||
113 | + } | ||
114 | + }) | ||
115 | + }) | ||
116 | + }) | ||
117 | + }) | ||
118 | + function sleep (time) { | ||
119 | + return new Promise((resolve) => setTimeout(resolve, time)); | ||
120 | + } | ||
121 | + } | ||
122 | +} | ||
123 | + | ||
124 | +//var driver = new webdriver.Builder() | ||
125 | +//.forBrowser('chrome') | ||
126 | +//.withCapabilities(webdriver.Capabilities.chrome()) | ||
127 | +//.build(); | ||
128 | + | ||
129 | +//search_broadcasting(driver,"people.search.naver.com/search.naver?where=nexearch&sm=tab_ppn&query=유재석&os=94702&ie=utf8&key=PeopleService","유재석",function() { | ||
130 | +// console.log("B") | ||
131 | +//}) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/crawling_samename.js
0 → 100644
1 | +var async = require('async'); | ||
2 | +var webdriver = require('selenium-webdriver'); | ||
3 | +var chrome = require('selenium-webdriver/chrome') | ||
4 | +var Options = new chrome.Options(); | ||
5 | +Options.addArguments('headless') | ||
6 | +Options.addArguments('disable-gpu') | ||
7 | +const fs = require('fs') | ||
8 | +var check = 0 | ||
9 | +var testStartRunTime = 0; | ||
10 | +var testruntime = 0; | ||
11 | + | ||
12 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
13 | + | ||
14 | +var next_link_list = [] | ||
15 | +var src_list = [] | ||
16 | +var text_list = [] | ||
17 | +var return_list = [] | ||
18 | + | ||
19 | +module.exports = { | ||
20 | + first_search :function (driver,string,callback) { | ||
21 | + | ||
22 | + function testRunTimer() { | ||
23 | + var today = new Date(); // 현재시간 얻기 | ||
24 | + var runTime = today.getTime(); // 밀리세컨드 ( 1970/01/01 부터 현재까지의 시간을 밀리세컨드로 나타냄 ) | ||
25 | + var rtn = 0; | ||
26 | + | ||
27 | + if (testStartRunTime == 0) { | ||
28 | + testStartRunTime = runTime; | ||
29 | + } else { | ||
30 | + rtn = (runTime - testStartRunTime) / 1000; | ||
31 | + testStartRunTime = 0; | ||
32 | + } | ||
33 | + return rtn; | ||
34 | + } | ||
35 | + let url1 = "https://people.search.naver.com/search.naver?sm=tab_hty&where=nexearch&query="+string+"&ie=utf8&x=0&y=0" | ||
36 | + driver | ||
37 | + .get(url1).then(() => { | ||
38 | + testRunTimer() | ||
39 | + driver | ||
40 | + .findElements(webdriver.By.className('result_profile')) | ||
41 | + .then(profiles => { | ||
42 | + profiles.forEach(profile => { | ||
43 | + profile.findElements(webdriver.By.className('thmb')) | ||
44 | + .then(links=> { | ||
45 | + links.forEach(link => { | ||
46 | + link.getAttribute('href') | ||
47 | + .then(next_link => { | ||
48 | + profile.findElements(webdriver.By.className('thmb_img')) | ||
49 | + .then((imgs) => { | ||
50 | + imgs.forEach(img => { | ||
51 | + img.getAttribute('src') | ||
52 | + .then(src => { | ||
53 | + next_link_list.push(next_link) | ||
54 | + src_list.push(src) | ||
55 | + //text_list.push(text) | ||
56 | + testruntime += testRunTimer() | ||
57 | + setTimeout(function() { | ||
58 | + check++; | ||
59 | + if(check==1) { | ||
60 | + //return_list.push(text_list) | ||
61 | + setTimeout(function() { | ||
62 | + fs.writeFileSync("./log/"+string+"_next_link.txt", '\ufeff' + next_link_list, {encoding: 'utf8'}); | ||
63 | + fs.writeFileSync("./log/"+string+"_img_src.txt", '\ufeff' + src_list, {encoding: 'utf8'}); | ||
64 | + callback() | ||
65 | + },500) | ||
66 | + } | ||
67 | + },testruntime*1000+1000) | ||
68 | + }) | ||
69 | + }) | ||
70 | + }) | ||
71 | + }) | ||
72 | + }) | ||
73 | + }) | ||
74 | + }) | ||
75 | + }) | ||
76 | + }) | ||
77 | + } | ||
78 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/crawling_time.js
0 → 100644
1 | +var webdriver = require('selenium-webdriver'); | ||
2 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
3 | +const fs = require('fs') | ||
4 | + | ||
5 | + var arr = [] | ||
6 | + var result_arr = [] | ||
7 | + var temp = [] | ||
8 | + var i=0 | ||
9 | + var check = 0 | ||
10 | +module.exports = { | ||
11 | + search_broadcasting_time : function(driver,broadcast,day,findtitle, callback) { | ||
12 | + let url1 = "https://search.naver.com/search.naver?sm=top_hty&fbm=0&ie=utf8&query="+broadcast+"+"+day+"+편성표" | ||
13 | + driver | ||
14 | + .get(url1).then(() => { | ||
15 | + driver | ||
16 | + .findElements(webdriver.By.className('cont_inner type_day _scheduleArea')) | ||
17 | + .then(contentsearch_section=> { | ||
18 | + contentsearch_section[0].findElements(webdriver.By.tagName('tbody')) | ||
19 | + .then(tbody => { | ||
20 | + tbody[0].findElements(webdriver.By.tagName('tr')) | ||
21 | + .then(trs => { | ||
22 | + trs.forEach(tr => { | ||
23 | + tr.getText() | ||
24 | + .then(content => { | ||
25 | + if(content.indexOf(findtitle) != -1) { | ||
26 | + arr = content.toString().split('\n') | ||
27 | + str(function() { | ||
28 | + i++ | ||
29 | + if(i==2) { | ||
30 | + fs.writeFileSync("./log/"+findtitle+"_time_detail.txt", '\ufeff' + result_arr, {encoding: 'utf8'}); | ||
31 | + callback() | ||
32 | + } | ||
33 | + }) | ||
34 | + function str(_callback) { | ||
35 | + temp[i+0] = arr[0] + " " + arr[1].substr(0,2) + "분" | ||
36 | + temp[i+1] = arr[1].substr(3) | ||
37 | + result_arr.push(temp[i+0],temp[i+1]) | ||
38 | + if(arr.length == 3) { | ||
39 | + temp[i+2] = arr[0] + " " + arr[2].substr(0,2) + "분" | ||
40 | + temp[i+3] = arr[2].substr(3) | ||
41 | + result_arr.push(temp[i+2],temp[i+3]) | ||
42 | + i++ | ||
43 | + } | ||
44 | + setTimeout(() => { | ||
45 | + _callback() | ||
46 | + }, 500); | ||
47 | + | ||
48 | + } | ||
49 | + } | ||
50 | + }) | ||
51 | + }) | ||
52 | + }) | ||
53 | + }) | ||
54 | + }) | ||
55 | + }) | ||
56 | + } | ||
57 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/런닝맨_br_isonair.txt
0 → 100644
1 | +SBS ,방영중,일요일,오후 04:50 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/런닝맨_time_detail.txt
0 → 100644
1 | +16시 50분,런닝맨 1부,17시 40분,런닝맨 2부 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/유재석_img_src.txt
0 → 100644
1 | +https://search.pstatic.net/common?type=a&size=60x76&quality=95&src=http://sstatic.naver.net/people/portrait/201808/20180828141741978.jpg,https://search.pstatic.net/common?type=a&size=60x76&quality=95&src=http://people.phinf.naver.net/20150328_223/1427473846485vwRXc_JPEG/chosun_400093103.jpg | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/유재석_img_src_br.txt
0 → 100644
1 | +https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/65/99/10/57_659910_poster_image_1506416659493.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/75/90/39/57_8759039_poster_image_1542880871064.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/75/91/55/57_8759155_poster_image_1540263433873.png,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/77/64/63/57_8776463_poster_image_1539219518133.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/66/33/78/57_8663378_poster_image_1534389778374.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/09/95/73/57_8099573_poster_image_1523413341476.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/44/21/84/57_6442184_poster_image_1514533716001.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/78/49/00/57_2784900_poster_image_1444978089345.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/44/71/54/57_2447154_poster_image_1433400789533.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/86/80/32/57_1868032_poster_image_1417592147530.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/67/49/81/57_674981_poster_image_1537158466551.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/164/164267.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/66/10/22/57_661022_poster_image_1457491725216.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/154/154271.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/154/154273.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/162/162685.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/159/159015.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/159/159705.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/0/0/160/160020.jpg,https://search.pstatic.net/common?type=mfullfill&size=96x138&quality=95&src=http://sstatic.naver.net/keypage/image/dss/57/65/91/74/57_659174_poster_image_1442911837885.jpg | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/유재석_next_link.txt
0 → 100644
1 | +https://people.search.naver.com/search.naver?where=nexearch&sm=tab_ppn&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&os=94702&ie=utf8&key=PeopleService,https://people.search.naver.com/search.naver?where=nexearch&sm=tab_ppn&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&os=362156&ie=utf8&key=PeopleService | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/log/유재석_title_br.txt
0 → 100644
1 | +무한도전,요즘애들,미추리 8-1000,해피투게더 4,유 퀴즈 온 더 블럭,범인은 바로 너!,투유 프로젝트 - 슈가맨 2,투유 프로젝트 - 슈가맨,동상이몽, 괜찮아 괜찮아!,나는 남자다,런닝맨,패밀리가 떴다 1,해피투게더 3,옛날 TV,하자 GO!,X맨 일요일이 좋다,강력추천 토요일,해피투게더 2,느낌표,공감토크쇼 놀러와 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
selenium-function/main.js
0 → 100644
1 | +var async = require('async'); | ||
2 | +var webdriver = require('selenium-webdriver'); | ||
3 | +//var options = {desiredCapabilities: {browserName: 'chrome'}}; | ||
4 | +var chrome = require('selenium-webdriver/chrome') | ||
5 | +var Options = new chrome.Options(); | ||
6 | +Options.addArguments('headless') | ||
7 | +Options.addArguments('disable-gpu') | ||
8 | +var test1 = require('./crawling_samename') | ||
9 | +const fs = require('fs') | ||
10 | +const test2 = require('./crawling_broadcasting') | ||
11 | +const test3 = require('./crawling_br_onair_date') | ||
12 | +const test4 = require('./crawling_time') | ||
13 | +var util = require('util') | ||
14 | +var EventEmitter = require('events').EventEmitter; | ||
15 | + | ||
16 | +var next_link_Array = [] | ||
17 | +var img_src_Array = [] | ||
18 | + | ||
19 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
20 | +var driver = new webdriver.Builder() | ||
21 | +.forBrowser('chrome') | ||
22 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
23 | +.setChromeOptions(Options) | ||
24 | +.build(); | ||
25 | + | ||
26 | +var driver_1 = new webdriver.Builder() | ||
27 | +.forBrowser('chrome') | ||
28 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
29 | +.setChromeOptions(Options) | ||
30 | +.build() | ||
31 | +var driver_2 = new webdriver.Builder() | ||
32 | +.forBrowser('chrome') | ||
33 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
34 | +.setChromeOptions(Options) | ||
35 | +.build(); | ||
36 | + | ||
37 | +var driver_3 = new webdriver.Builder() | ||
38 | +.forBrowser('chrome') | ||
39 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
40 | +.setChromeOptions(Options) | ||
41 | +.build(); | ||
42 | +var First_Search = function(name) { | ||
43 | + var self=this; | ||
44 | + this.on('input', function() { | ||
45 | + | ||
46 | + if(fs.existsSync("./log/"+name+"_next_link.txt")) { | ||
47 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
48 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
49 | + next_link_Array = next_link.toString().split(','); | ||
50 | + img_src_Array = img_src.toString().split(','); | ||
51 | + driver.quit() | ||
52 | + console.log(next_link_Array) | ||
53 | + console.log(img_src_Array) | ||
54 | + | ||
55 | + setTimeout(function() { | ||
56 | + br_search.emit('click') | ||
57 | + },1000) | ||
58 | + | ||
59 | + } | ||
60 | + else { | ||
61 | + test1.first_search(driver,name,function() { | ||
62 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
63 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
64 | + next_link_Array = next_link.toString().split(','); | ||
65 | + img_src_Array = img_src.toString().split(','); | ||
66 | + br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
67 | + console.log(next_link_Array) | ||
68 | + console.log(img_src_Array) | ||
69 | + driver.quit() | ||
70 | + setTimeout(function() { | ||
71 | + br_search.emit('click') | ||
72 | + },1000) | ||
73 | + }) | ||
74 | + } | ||
75 | + }) | ||
76 | +} | ||
77 | +util.inherits(First_Search,EventEmitter); | ||
78 | +first_search1 = new First_Search("유재석") | ||
79 | +first_search1.emit('input') | ||
80 | + | ||
81 | +var img_src_br_list = [] | ||
82 | +var title_list = [] | ||
83 | +var broadcasting_search = function(next_link,name,num) { | ||
84 | + var self=this; | ||
85 | + this.on('click', function() { | ||
86 | + if(fs.existsSync("./log/"+name+"_img_src_br.txt")) { | ||
87 | + const img_src_br = fs.readFileSync("./log/"+name+"_img_src_br.txt"); | ||
88 | + img_src_br_list = img_src_br.toString().split(','); | ||
89 | + const title_br = fs.readFileSync("./log/"+name+"_title_br.txt"); | ||
90 | + title_list = title_br.toString().split(','); | ||
91 | + driver_1.quit() | ||
92 | + console.log(img_src_br_list) | ||
93 | + console.log(title_list) | ||
94 | + is_onair.emit('click_1') | ||
95 | + } | ||
96 | + else { | ||
97 | + test2.search_broadcasting(driver_1,next_link[num].substr(9),name,function() { | ||
98 | + const img_src_br = fs.readFileSync("./log/"+name+"_img_src_br.txt"); | ||
99 | + img_src_br_list = img_src_br.toString().split(','); | ||
100 | + const title_br = fs.readFileSync("./log/"+name+"_title_br.txt"); | ||
101 | + title_list = title_br.toString().split(','); | ||
102 | + | ||
103 | + driver_1.quit() | ||
104 | + console.log(img_src_br_list) | ||
105 | + console.log(title_list) | ||
106 | + is_onair.emit('click_1') | ||
107 | + }) | ||
108 | + } | ||
109 | + }) | ||
110 | +} | ||
111 | +util.inherits(broadcasting_search,EventEmitter); | ||
112 | +br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
113 | + | ||
114 | +br_datalist = [] | ||
115 | +var isonair = function(num) { | ||
116 | + var self = this | ||
117 | + this.on('click_1',function() { | ||
118 | + if(fs.existsSync("./log/"+title_list[num]+"_br_isonair.txt")) { | ||
119 | + const img_src_br = fs.readFileSync("./log/"+title_list[num]+"_br_isonair.txt"); | ||
120 | + br_datalist = img_src_br.toString().split(','); | ||
121 | + br_datalist[0] = br_datalist[0].trim() | ||
122 | + console.log(br_datalist) | ||
123 | + Search_detail_time.emit('click_2') | ||
124 | + } | ||
125 | + | ||
126 | + else { | ||
127 | + test3.search_onairanddate(driver_2,title_list[num],function() { | ||
128 | + const img_src_br = fs.readFileSync("./log/"+title_list[num]+"_br_isonair.txt"); | ||
129 | + br_datalist = img_src_br.toString().split(','); | ||
130 | + br_datalist[0] = br_datalist[0].trim() | ||
131 | + console.log(br_datalist) | ||
132 | + Search_detail_time.emit('click_2') | ||
133 | + }) | ||
134 | + } | ||
135 | + }) | ||
136 | +} | ||
137 | + | ||
138 | +util.inherits(isonair,EventEmitter); | ||
139 | +is_onair = new isonair(11) | ||
140 | + | ||
141 | +var detail_time_list = [] | ||
142 | +var search_detail_time = function(num) { | ||
143 | + var self = this; | ||
144 | + this.on('click_2',function() { | ||
145 | + if(br_datalist[1] == "방영중") { | ||
146 | + if(fs.existsSync("./log/"+title_list[num]+"_time_detail.txt")) { | ||
147 | + const detail = fs.readFileSync("./log/"+title_list[num]+"_time_detail.txt"); | ||
148 | + detail_time_list = detail.toString().split(','); | ||
149 | + console.log(detail_time_list) | ||
150 | + } | ||
151 | + else { | ||
152 | + test4.search_broadcasting_time(driver_3,br_datalist[0],br_datalist[2],title_list[num],function(){ | ||
153 | + const detail = fs.readFileSync("./log/"+title_list[num]+"_time_detail.txt"); | ||
154 | + detail_time_list = detail.toString().split(','); | ||
155 | + console.log(detail_time_list) | ||
156 | + }) | ||
157 | + | ||
158 | + } | ||
159 | + } | ||
160 | + }) | ||
161 | +} | ||
162 | + | ||
163 | +util.inherits(search_detail_time,EventEmitter); | ||
164 | +Search_detail_time = new search_detail_time(11); |
selenium-function/package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
selenium-function/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "cheerio", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "practice.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "author": "", | ||
10 | + "license": "ISC", | ||
11 | + "dependencies": { | ||
12 | + "async": "^2.6.1", | ||
13 | + "events": "^3.0.0", | ||
14 | + "fs": "0.0.1-security", | ||
15 | + "iconv-lite": "^0.4.24", | ||
16 | + "jason": "^2.0.0", | ||
17 | + "json": "^9.0.6", | ||
18 | + "selenium-webdriver": "^3.6.0", | ||
19 | + "util": "^0.11.1", | ||
20 | + "webdriverio": "^4.14.0" | ||
21 | + } | ||
22 | +} |
selenium-function/동명이인/sdfasdfasd.js
0 → 100644
1 | +var async = require('async'); | ||
2 | +var webdriver = require('selenium-webdriver'); | ||
3 | +//var options = {desiredCapabilities: {browserName: 'chrome'}}; | ||
4 | +var chrome = require('selenium-webdriver/chrome') | ||
5 | +var Options = new chrome.Options(); | ||
6 | +Options.addArguments('headless') | ||
7 | +Options.addArguments('disable-gpu') | ||
8 | +var test1 = require('./crawling_samename') | ||
9 | +const fs = require('fs') | ||
10 | +var util = require('util') | ||
11 | +var EventEmitter = require('events').EventEmitter; | ||
12 | + | ||
13 | +var next_link_Array = [] | ||
14 | +var img_src_Array = [] | ||
15 | + | ||
16 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
17 | +var driver = new webdriver.Builder() | ||
18 | +.forBrowser('chrome') | ||
19 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
20 | +.setChromeOptions(Options) | ||
21 | +.build(); | ||
22 | + | ||
23 | +var First_Search = function(name) { | ||
24 | + var self=this; | ||
25 | + this.on('input', function() { | ||
26 | + | ||
27 | + if(fs.existsSync("./log/"+name+"_next_link.txt")) { | ||
28 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
29 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
30 | + next_link_Array = next_link.toString().split(','); | ||
31 | + img_src_Array = img_src.toString().split(','); | ||
32 | + driver.quit() | ||
33 | + console.log(next_link_Array) | ||
34 | + console.log(img_src_Array) | ||
35 | + | ||
36 | + setTimeout(function() { | ||
37 | + br_search.emit('click') | ||
38 | + },1000) | ||
39 | + | ||
40 | + } | ||
41 | + else { | ||
42 | + test1.first_search(driver,name,function() { | ||
43 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
44 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
45 | + next_link_Array = next_link.toString().split(','); | ||
46 | + img_src_Array = img_src.toString().split(','); | ||
47 | + br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
48 | + console.log(next_link_Array) | ||
49 | + console.log(img_src_Array) | ||
50 | + driver.quit() | ||
51 | + setTimeout(function() { | ||
52 | + br_search.emit('click') | ||
53 | + },1000) | ||
54 | + }) | ||
55 | + } | ||
56 | + }) | ||
57 | +} | ||
58 | +util.inherits(First_Search,EventEmitter); | ||
59 | +first_search1 = new First_Search("유재석") | ||
60 | +first_search1.emit('input') |
-
Please register or login to post a comment