Showing
12 changed files
with
2 additions
and
670 deletions
.gitignore
0 → 100644
README.md
deleted
100644 → 0
chromedriver.exe
deleted
100644 → 0
No preview for this file type
crawling_br_onair_date.js
deleted
100644 → 0
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 | - | ||
36 | - callback() | ||
37 | - }) | ||
38 | - }) | ||
39 | - }) | ||
40 | - }) | ||
41 | - }) | ||
42 | - }) | ||
43 | - driver.findElement(webdriver.By.className('brcs_thumb')) | ||
44 | - .then(brcs_thumb => { | ||
45 | - brcs_thumb.findElements(webdriver.By.tagName('img')) | ||
46 | - .then( img => { | ||
47 | - img[0].getAttribute('src') | ||
48 | - .then(img_src => { | ||
49 | - datalist.push(img_src) | ||
50 | - }) | ||
51 | - }) | ||
52 | - }) | ||
53 | - } | ||
54 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
crawling_broadcasting.js
deleted
100644 → 0
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 |
crawling_samename.js
deleted
100644 → 0
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 |
crawling_time.js
deleted
100644 → 0
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 |
main.js
deleted
100644 → 0
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 JASON = require('jason') | ||
9 | -var test1 = require('./crawling_samename') | ||
10 | -const fs = require('fs') | ||
11 | -const test2 = require('./crawling_broadcasting') | ||
12 | -const test3 = require('./crawling_br_onair_date') | ||
13 | -const test4 = require('./crawling_time') | ||
14 | -var util = require('util') | ||
15 | -var EventEmitter = require('events').EventEmitter; | ||
16 | - | ||
17 | -var next_link_Array = [] | ||
18 | -var img_src_Array = [] | ||
19 | - | ||
20 | -const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
21 | -var driver = new webdriver.Builder() | ||
22 | -.forBrowser('chrome') | ||
23 | -.withCapabilities(webdriver.Capabilities.chrome()) | ||
24 | -.setChromeOptions(Options) | ||
25 | -.build(); | ||
26 | - | ||
27 | -var driver_1 = new webdriver.Builder() | ||
28 | -.forBrowser('chrome') | ||
29 | -.withCapabilities(webdriver.Capabilities.chrome()) | ||
30 | -.setChromeOptions(Options) | ||
31 | -.build() | ||
32 | -var driver_2 = new webdriver.Builder() | ||
33 | -.forBrowser('chrome') | ||
34 | -.withCapabilities(webdriver.Capabilities.chrome()) | ||
35 | -.setChromeOptions(Options) | ||
36 | -.build(); | ||
37 | - | ||
38 | -var driver_3 = new webdriver.Builder() | ||
39 | -.forBrowser('chrome') | ||
40 | -.withCapabilities(webdriver.Capabilities.chrome()) | ||
41 | -.setChromeOptions(Options) | ||
42 | -.build(); | ||
43 | -var First_Search = function(name) { | ||
44 | - var self=this; | ||
45 | - this.on('input', function() { | ||
46 | - | ||
47 | - if(fs.existsSync("./log/"+name+"_next_link.txt")) { | ||
48 | - const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
49 | - const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
50 | - next_link_Array = next_link.toString().split(','); | ||
51 | - img_src_Array = img_src.toString().split(','); | ||
52 | - driver.quit() | ||
53 | - console.log(next_link_Array) | ||
54 | - console.log(img_src_Array) | ||
55 | - | ||
56 | - setTimeout(function() { | ||
57 | - br_search.emit('click') | ||
58 | - },1000) | ||
59 | - | ||
60 | - } | ||
61 | - else { | ||
62 | - test1.first_search(driver,name,function() { | ||
63 | - const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
64 | - const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
65 | - next_link_Array = next_link.toString().split(','); | ||
66 | - img_src_Array = img_src.toString().split(','); | ||
67 | - br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
68 | - console.log(next_link_Array) | ||
69 | - console.log(img_src_Array) | ||
70 | - driver.quit() | ||
71 | - setTimeout(function() { | ||
72 | - br_search.emit('click') | ||
73 | - },1000) | ||
74 | - }) | ||
75 | - } | ||
76 | - }) | ||
77 | -} | ||
78 | -util.inherits(First_Search,EventEmitter); | ||
79 | -first_search1 = new First_Search("유재석") | ||
80 | -first_search1.emit('input') | ||
81 | - | ||
82 | -var img_src_br_list = [] | ||
83 | -var title_list = [] | ||
84 | -var broadcasting_search = function(next_link,name,num) { | ||
85 | - var self=this; | ||
86 | - this.on('click', function() { | ||
87 | - if(fs.existsSync("./log/"+name+"_img_src_br.txt")) { | ||
88 | - const img_src_br = fs.readFileSync("./log/"+name+"_img_src_br.txt"); | ||
89 | - img_src_br_list = img_src_br.toString().split(','); | ||
90 | - const title_br = fs.readFileSync("./log/"+name+"_title_br.txt"); | ||
91 | - title_list = title_br.toString().split(','); | ||
92 | - driver_1.quit() | ||
93 | - console.log(img_src_br_list) | ||
94 | - console.log(title_list) | ||
95 | - is_onair.emit('click_1') | ||
96 | - } | ||
97 | - else { | ||
98 | - test2.search_broadcasting(driver_1,next_link[num].substr(9),name,function() { | ||
99 | - const img_src_br = fs.readFileSync("./log/"+name+"_img_src_br.txt"); | ||
100 | - img_src_br_list = img_src_br.toString().split(','); | ||
101 | - const title_br = fs.readFileSync("./log/"+name+"_title_br.txt"); | ||
102 | - title_list = title_br.toString().split(','); | ||
103 | - | ||
104 | - driver_1.quit() | ||
105 | - console.log(img_src_br_list) | ||
106 | - console.log(title_list) | ||
107 | - is_onair.emit('click_1') | ||
108 | - }) | ||
109 | - } | ||
110 | - }) | ||
111 | -} | ||
112 | -util.inherits(broadcasting_search,EventEmitter); | ||
113 | -br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
114 | - | ||
115 | -br_datalist = [] | ||
116 | -var isonair = function(num) { | ||
117 | - var self = this | ||
118 | - this.on('click_1',function() { | ||
119 | - if(fs.existsSync("./log/"+title_list[num]+"_br_isonair.txt")) { | ||
120 | - const img_src_br = fs.readFileSync("./log/"+title_list[num]+"_br_isonair.txt"); | ||
121 | - br_datalist = img_src_br.toString().split(','); | ||
122 | - br_datalist[0] = br_datalist[0].trim() | ||
123 | - console.log(br_datalist) | ||
124 | - Search_detail_time.emit('click_2') | ||
125 | - } | ||
126 | - | ||
127 | - else { | ||
128 | - test3.search_onairanddate(driver_2,title_list[num],function() { | ||
129 | - const img_src_br = fs.readFileSync("./log/"+title_list[num]+"_br_isonair.txt"); | ||
130 | - br_datalist = img_src_br.toString().split(','); | ||
131 | - br_datalist[0] = br_datalist[0].trim() | ||
132 | - console.log(br_datalist) | ||
133 | - Search_detail_time.emit('click_2') | ||
134 | - }) | ||
135 | - } | ||
136 | - }) | ||
137 | -} | ||
138 | - | ||
139 | -util.inherits(isonair,EventEmitter); | ||
140 | -is_onair = new isonair(11) | ||
141 | - | ||
142 | -var detail_time_list = [] | ||
143 | -var search_detail_time = function(num) { | ||
144 | - var self = this; | ||
145 | - this.on('click_2',function() { | ||
146 | - if(br_datalist[1] == "방영중") { | ||
147 | - if(fs.existsSync("./log/"+title_list[num]+"_time_detail.txt")) { | ||
148 | - const detail = fs.readFileSync("./log/"+title_list[num]+"_time_detail.txt"); | ||
149 | - detail_time_list = detail.toString().split(','); | ||
150 | - console.log(detail_time_list) | ||
151 | - } | ||
152 | - else { | ||
153 | - test4.search_broadcasting_time(driver_3,br_datalist[0],br_datalist[2],title_list[num],function(){ | ||
154 | - const detail = fs.readFileSync("./log/"+title_list[num]+"_time_detail.txt"); | ||
155 | - detail_time_list = detail.toString().split(','); | ||
156 | - console.log(detail_time_list) | ||
157 | - }) | ||
158 | - | ||
159 | - } | ||
160 | - } | ||
161 | - }) | ||
162 | -} | ||
163 | - | ||
164 | -util.inherits(search_detail_time,EventEmitter); | ||
165 | -Search_detail_time = new search_detail_time(11); |
package-lock.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
package.json
deleted
100644 → 0
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 | -} |
practice.js
deleted
100644 → 0
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 | - | ||
6 | -var driver = new webdriver.Builder(). | ||
7 | - withCapabilities(webdriver.Capabilities.chrome()). | ||
8 | - build(); | ||
9 | - | ||
10 | - let url = 'https://people.search.naver.com/search.naver?where=nexearch&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&sm=tab_etc&ie=utf8&key=PeopleService&os=94702'; | ||
11 | - | ||
12 | - driver | ||
13 | - .get(url) | ||
14 | - .then(() => { | ||
15 | - driver | ||
16 | - .findElement(webdriver.By.id('pagination_76')) | ||
17 | - .then(paginationBtn => { | ||
18 | - paginationBtn.findElements(webdriver.By.className('bt_next')) | ||
19 | - .then(elemsBtn => { | ||
20 | - var cnt = 1; | ||
21 | - | ||
22 | - function getContentsAndClickNext (callback) { | ||
23 | - console.log('higetcontests', cnt); | ||
24 | - cnt++; | ||
25 | - driver | ||
26 | - .findElement(webdriver.By.id('listUI_76')) | ||
27 | - .then(contentsUI => { | ||
28 | - contentsUI | ||
29 | - .findElements(webdriver.By.tagName('li')) | ||
30 | - .then(elems => { | ||
31 | - elems.forEach(elem => { | ||
32 | - elem | ||
33 | - .getText() | ||
34 | - .then(text => { | ||
35 | - console.log(text); | ||
36 | - // 내 추측 : stale해지면, boolean 값으로 driver 어딘가에 true설정되는것 같아 | ||
37 | - // wait이라는 함수를 써서, 이게 false 가 될 때까지 기다린 다음에 getText()를 해. | ||
38 | - // ok? | ||
39 | - }) | ||
40 | - .catch(error => { | ||
41 | - // 문제가 있으면 이곳을 의심해볼것! 변수 error를 체크해보기! | ||
42 | - // console.log('really?? exception!'); | ||
43 | - }) | ||
44 | - }) | ||
45 | - | ||
46 | - elemsBtn[0].click(); | ||
47 | - | ||
48 | - sleep(50).then(() => { | ||
49 | - // Do something after the sleep! | ||
50 | - }); | ||
51 | - callback(); | ||
52 | - }) | ||
53 | - .catch(error => { | ||
54 | - console.log("asdfasdf!!', e"); | ||
55 | - }) | ||
56 | - }) | ||
57 | - .catch(error => { | ||
58 | - console.log('fuck!@#', error); | ||
59 | - }) | ||
60 | - } | ||
61 | - | ||
62 | - async.whilst( | ||
63 | - function() { | ||
64 | - console.log('whilist result', cnt < 5); | ||
65 | - return cnt < 5; | ||
66 | - }, | ||
67 | - getContentsAndClickNext, | ||
68 | - function(e) { | ||
69 | - console.log('Exception', e) | ||
70 | - } | ||
71 | - ); | ||
72 | - }) | ||
73 | - .catch(error => { | ||
74 | - console.log('Exception 4444', error); | ||
75 | - }); // 다음 컨텐츠로 가는 버튼(2개임. 하나는 평소용 두번째는 더이상 갈 페이지가 없을 때 쓰는 버튼) | ||
76 | - }) | ||
77 | - .catch(error => { | ||
78 | - console.log('Exception 555', error); | ||
79 | - }); // 방송 컨텐츠 페이지네이션 버튼 | ||
80 | - | ||
81 | - | ||
82 | - // sleep time expects milliseconds | ||
83 | - function sleep (time) { | ||
84 | - return new Promise((resolve) => setTimeout(resolve, time)); | ||
85 | - } | ||
86 | - | ||
87 | - // Usage! | ||
88 | - sleep(8000).then(() => { | ||
89 | - // Do something after the sleep! | ||
90 | - }); | ||
91 | - | ||
92 | - }); | ||
93 | - |
동명이인/sdfasdfasd.js
deleted
100644 → 0
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