Showing
1 changed file
with
15 additions
and
18 deletions
... | @@ -77,40 +77,37 @@ async.waterfall([ | ... | @@ -77,40 +77,37 @@ async.waterfall([ |
77 | "theater_name" : await theater.getAttribute('title'), | 77 | "theater_name" : await theater.getAttribute('title'), |
78 | "theater_code" : await theater.getAttribute('href')//.replace("(.+(?<=theaterCode=))|(.+(?<=theatercode=))", "").substring(0,4) | 78 | "theater_code" : await theater.getAttribute('href')//.replace("(.+(?<=theaterCode=))|(.+(?<=theatercode=))", "").substring(0,4) |
79 | }; | 79 | }; |
80 | - theater_info.theater_code = theater_info.theater_code.replace("(.+(?<=theaterCode=))|(.+(?<=theatercode=))", "").substring(0,4); | 80 | + theater_info.theater_code = theater_info.theater_code.replace(/(.+(?<=theaterCode=))|(.+(?<=theatercode=))/, "").substring(0,4); |
81 | theaters_info_by_area.push(theater_info); | 81 | theaters_info_by_area.push(theater_info); |
82 | - n++; | ||
83 | - //console.log(theater_info); | ||
84 | } | 82 | } |
85 | cgv_theaters.push(theaters_info_by_area); | 83 | cgv_theaters.push(theaters_info_by_area); |
86 | } | 84 | } |
87 | - console.log(n); | ||
88 | - | ||
89 | driver_theaters.close(); | 85 | driver_theaters.close(); |
90 | }, | 86 | }, |
91 | async () => { | 87 | async () => { |
92 | const driver_movies = new webdriver.Builder().forBrowser('chrome').setChromeOptions(new chrome.Options().headless()).build(); | 88 | const driver_movies = new webdriver.Builder().forBrowser('chrome').setChromeOptions(new chrome.Options().headless()).build(); |
93 | driver_movies.get(url_movies); | 89 | driver_movies.get(url_movies); |
94 | //예매율 Top19까지의 영화의 정보를 가져옴. | 90 | //예매율 Top19까지의 영화의 정보를 가져옴. |
95 | - let chart = await driver_movies.wait(until.elementLocated(By.className("sect-movie-chart"))); | 91 | + |
96 | - const rank = chart.findElements(By.css("strong.rank")); | 92 | + //let chart = await driver_movies.wait(until.elementLocated(By.className("sect-movie-chart"))); |
97 | - const title = chart.findElements(By.css("strong.title")); | 93 | + const rank = await driver_movies.wait(until.elementsLocated(By.css("strong.rank"))); |
98 | - const score = chart.findElements(By.css("strong.percent")); | 94 | + const title = await driver_movies.wait(until.elementsLocated(By.css("strong.title"))); |
99 | - const GoldenEgg = chart.findElements(By.css("span.percent")); | 95 | + const score = await driver_movies.wait(until.elementsLocated(By.css("strong.percent"))); |
100 | - const link = chart.findElements(By.css("a.plink-reservation")); | 96 | + const GoldenEgg = await driver_movies.wait(until.elementsLocated(By.css("span.percent"))); |
101 | - | 97 | + const link = await driver_movies.wait(until.elementsLocated(By.css("a.link-reservation"))); |
98 | + | ||
102 | //영화 제목, 순위, 예매율, 영화 코드, 골든에그 지수를 가져와 CGVMovieInfo 객체 생성자에 파라미터로 넘겨주고, 인스턴스를 받아옴. | 99 | //영화 제목, 순위, 예매율, 영화 코드, 골든에그 지수를 가져와 CGVMovieInfo 객체 생성자에 파라미터로 넘겨주고, 인스턴스를 받아옴. |
103 | for (let i = 0; i < rank.length; i++) { | 100 | for (let i = 0; i < rank.length; i++) { |
104 | - const newTitle = title[i]; | 101 | + const newTitle = await title[i].getText(); |
105 | - const newRank = parseInt(rank[i].replace("No.", "")); | 102 | + const newRank = await rank[i].getText(); |
106 | - const newScore = score[i].replace("예매율", "").replace("%", ""); | 103 | + const newScore = await score[i].getText(); |
107 | - const newCode = link[i].getAttribute("href").replace(("[^0-9]", "")).substring(0,8); | 104 | + const newCode = await link[i].getAttribute("href"); |
108 | - const newMovie = new CGVMovieInfo(newTitle, newRank, newScore, GoldenEgg[i], newCode); | 105 | + const newMovie = new CGVMovieInfo(newTitle, parseInt(newRank.replace("No.", "")), newScore.replace("예매율", "").replace("%", ""), await GoldenEgg[i].getText(), newCode.replace(/[^0-9]/, "").substring(0,8)); |
109 | cgv_movies.push(newMovie); | 106 | cgv_movies.push(newMovie); |
110 | } | 107 | } |
111 | driver_movies.close(); | 108 | driver_movies.close(); |
112 | } | 109 | } |
113 | -]); | 110 | +]) |
114 | 111 | ||
115 | app.get('/cgv_theaters', (req, res) => { | 112 | app.get('/cgv_theaters', (req, res) => { |
116 | res.send(cgv_theaters[0]); | 113 | res.send(cgv_theaters[0]); | ... | ... |
-
Please register or login to post a comment