임승현

Enable to load top19 movies

......@@ -77,40 +77,37 @@ async.waterfall([
"theater_name" : await theater.getAttribute('title'),
"theater_code" : await theater.getAttribute('href')//.replace("(.+(?<=theaterCode=))|(.+(?<=theatercode=))", "").substring(0,4)
};
theater_info.theater_code = theater_info.theater_code.replace("(.+(?<=theaterCode=))|(.+(?<=theatercode=))", "").substring(0,4);
theater_info.theater_code = theater_info.theater_code.replace(/(.+(?<=theaterCode=))|(.+(?<=theatercode=))/, "").substring(0,4);
theaters_info_by_area.push(theater_info);
n++;
//console.log(theater_info);
}
cgv_theaters.push(theaters_info_by_area);
}
console.log(n);
driver_theaters.close();
},
async () => {
const driver_movies = new webdriver.Builder().forBrowser('chrome').setChromeOptions(new chrome.Options().headless()).build();
driver_movies.get(url_movies);
//예매율 Top19까지의 영화의 정보를 가져옴.
let chart = await driver_movies.wait(until.elementLocated(By.className("sect-movie-chart")));
const rank = chart.findElements(By.css("strong.rank"));
const title = chart.findElements(By.css("strong.title"));
const score = chart.findElements(By.css("strong.percent"));
const GoldenEgg = chart.findElements(By.css("span.percent"));
const link = chart.findElements(By.css("a.plink-reservation"));
//let chart = await driver_movies.wait(until.elementLocated(By.className("sect-movie-chart")));
const rank = await driver_movies.wait(until.elementsLocated(By.css("strong.rank")));
const title = await driver_movies.wait(until.elementsLocated(By.css("strong.title")));
const score = await driver_movies.wait(until.elementsLocated(By.css("strong.percent")));
const GoldenEgg = await driver_movies.wait(until.elementsLocated(By.css("span.percent")));
const link = await driver_movies.wait(until.elementsLocated(By.css("a.link-reservation")));
//영화 제목, 순위, 예매율, 영화 코드, 골든에그 지수를 가져와 CGVMovieInfo 객체 생성자에 파라미터로 넘겨주고, 인스턴스를 받아옴.
for (let i = 0; i < rank.length; i++) {
const newTitle = title[i];
const newRank = parseInt(rank[i].replace("No.", ""));
const newScore = score[i].replace("예매율", "").replace("%", "");
const newCode = link[i].getAttribute("href").replace(("[^0-9]", "")).substring(0,8);
const newMovie = new CGVMovieInfo(newTitle, newRank, newScore, GoldenEgg[i], newCode);
const newTitle = await title[i].getText();
const newRank = await rank[i].getText();
const newScore = await score[i].getText();
const newCode = await link[i].getAttribute("href");
const newMovie = new CGVMovieInfo(newTitle, parseInt(newRank.replace("No.", "")), newScore.replace("예매율", "").replace("%", ""), await GoldenEgg[i].getText(), newCode.replace(/[^0-9]/, "").substring(0,8));
cgv_movies.push(newMovie);
}
driver_movies.close();
}
]);
])
app.get('/cgv_theaters', (req, res) => {
res.send(cgv_theaters[0]);
......