이혜인

adding movie info

...@@ -17,6 +17,23 @@ let movie_data = []; ...@@ -17,6 +17,23 @@ let movie_data = [];
17 17
18 (async () => { 18 (async () => {
19 19
20 + const driver = new webdriver.Builder().forBrowser('chrome').build();
21 + driver.get(booking_url);
22 + driver.switchTo().frame(0)//frameBokdMBooking 프레임 가져옴
23 +
24 + let list = await driver.wait(until.elementsLocated(By.css('#mCSB_1_container>ul>li>.btn')));
25 + r = 0;
26 + for (item of list) {
27 + //Using getAttribute to get the data
28 + movie_data[r++] = {
29 + 'rank' : r,
30 + 'title' : await item.getAttribute("movie-nm"),
31 + 'movie_num':await item.getAttribute("movie-no"),
32 + 'running':await item.getAttribute("form-at"),
33 + }
34 + }
35 + driver.close();
36 +
20 r = 0; 37 r = 0;
21 const browser = await puppeteer.launch({ 38 const browser = await puppeteer.launch({
22 headless: true 39 headless: true
...@@ -31,6 +48,11 @@ let movie_data = []; ...@@ -31,6 +48,11 @@ let movie_data = [];
31 const name = $(list).find('div.tit-area > p.tit').attr('title'); 48 const name = $(list).find('div.tit-area > p.tit').attr('title');
32 const rate = $(list).find('div.rate-date > span.rate').text(); 49 const rate = $(list).find('div.rate-date > span.rate').text();
33 50
51 + if(movie_data[r].title === name){
52 + movie_data[r]['rate'] = rate;
53 + }else{
54 + movie_data[r]['rate'] = '예매율 0.0%';
55 + }
34 }); 56 });
35 r = 0; 57 r = 0;
36 for(i of movie_data){ 58 for(i of movie_data){
...@@ -40,6 +62,11 @@ let movie_data = []; ...@@ -40,6 +62,11 @@ let movie_data = [];
40 browser.close(); 62 browser.close();
41 })(); 63 })();
42 64
65 +// (async () => {
66 +
67 +
68 +// })();
69 +
43 70
44 71
45 72
......