Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이혜인
/
Multiplex_Ticketing_Platform
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이혜인
2022-06-07 02:31:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b8a28b47fe0f9dbb3b66fecba50c4f210f598670
b8a28b47
1 parent
a104d8b8
modify getting playingmovielist
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
36 deletions
Chatbot/Megabox.js
Chatbot/app.js
Chatbot/package.json
Chatbot/Megabox.js
View file @
b8a28b4
const
chatbot
=
require
(
"./app.js"
);
const
request
=
require
(
'request'
);
const
cheerio
=
require
(
'cheerio'
);
const
puppeteer
=
require
(
'puppeteer'
);
require
(
'chromedriver'
);
const
{
Builder
,
until
}
=
require
(
'selenium-webdriver'
);
//모듈 불러오기
var
webdriver
=
require
(
'selenium-webdriver'
);
var
By
=
webdriver
.
By
;
const
chrome
=
require
(
'selenium-webdriver/chrome'
);
//크롬 사용시
const
async
=
require
(
'async'
)
let
express
=
require
(
'express'
);
let
app
=
express
();
...
...
@@ -17,27 +14,20 @@ let bodyParser = require('body-parser');
const
{
timeout
}
=
require
(
'async'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
const
booking_url
=
"https://megabox.co.kr/booking?"
;
exports
.
booking_url
=
booking_url
;
const
rate_url
=
"https://www.megabox.co.kr/movie"
;
let
r
=
0
;
let
movie_data
=
[];
exports
.
movie_data
=
movie_data
;
let
location_data
=
[];
exports
.
location_data
=
location_data
;
let
index
=
0
;
exports
.
init
=
()
=>
{
async
.
waterfall
([
//for 동기적 처리
async
()
=>
{
const
driver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
//
driver
.
get
(
booking_url
);
driver
.
switchTo
().
frame
(
0
)
//frameBokdMBooking 프레임 가져옴
let
seoul
=
await
driver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_4_container>ul>li>#btn'
)));
let
Gyeonggi
=
await
driver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_5_container>ul>li>#btn'
)));
const
Incheon
=
await
driver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_6_container>ul>li>#btn'
)));
...
...
@@ -50,7 +40,7 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
for
(
item
of
location_list
[
i
])
{
location_data
[
index
++
]
=
{
'LocationName'
:
await
item
.
getAttribute
(
"brch-nm"
),
'LocationN
U
m'
:
await
item
.
getAttribute
(
"brch-no"
)
'LocationN
u
m'
:
await
item
.
getAttribute
(
"brch-no"
)
}
// let location_name = await item.getAttribute("brch-nm");
// let location_num = await item.getAttribute("brch-no");
...
...
@@ -59,14 +49,12 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
// location_data[index++] = obj;
}
}
let
movie_list
=
await
driver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_1_container>ul>li>.btn'
)));
r
=
0
;
for
(
item
of
movie_list
)
{
//Using getAttribute to get the data
movie_data
[
r
++
]
=
{
'rank'
:
r
,
'title'
:
await
item
.
getAttribute
(
"movie-nm"
),
'movie_num'
:
await
item
.
getAttribute
(
"movie-no"
),
}
...
...
@@ -75,9 +63,7 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
driver
.
close
();
},
async
()
=>
{
r
=
0
;
const
browser
=
await
puppeteer
.
launch
({
headless
:
true
...
...
@@ -101,16 +87,16 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
movie_data
[
r
++
][
'rate'
]
=
'예매율 0%'
;
}
}
console
.
log
(
"completed"
)
browser
.
close
();
console
.
log
(
"Comepleted!"
);
},
])}
const
appdriver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
let
appdriver
;
exports
.
using_PlayingMovieURL
=
async
(
PlayingMovieURL
)
=>
{
appdriver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
appdriver
.
get
(
PlayingMovieURL
);
//appdriver.switchTo().frame(0)
//frameBokdMBooking 프레임 가져옴
...
...
@@ -118,24 +104,12 @@ exports.using_PlayingMovieURL = async(PlayingMovieURL) => {
exports
.
geting_PlayingMovie
=
async
()
=>
{
let
movie_list
=
await
appdriver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_1_container>ul>li>.btn'
)));
let
n
=
0
;
console
.
log
(
movie_list
);
for
(
item
of
movie_list
)
{
movie_data
[
n
++
][
'running'
]
=
await
item
.
getAttribute
(
'form-at'
)
console
.
log
(
item
.
getAttribute
(
'form-at'
))
movie_data
[
n
++
][
'running'
]
=
await
item
.
getAttribute
(
'form-at'
);
}
console
.
log
(
"completed"
)
console
.
log
(
"Completed get Running"
);
}
app
.
get
(
'/Megabox/GetPlayingMovie'
,
async
(
req
,
res
,
next
)
=>
{
//영화 상영 여부 객체에 넣음
// let movie_list = await appdriver.wait(until.elementsLocated(By.css('#mCSB_1_container>ul>li>.btn')));
// let n = 0;
// for (item of movie_list) {
// movie_data[n++]['running'] = await item.getAttribute('form-at')
// }
using_PlayingMovieURL
(
'https://megabox.co.kr/booking?brchNo1=4451&playDe=20220606'
);
geting_PlayingMovie
();
res
.
send
(
PlayingMovieList
);
})
app
.
listen
(
8000
);
\ No newline at end of file
app
.
listen
(
5000
);
\ No newline at end of file
...
...
Chatbot/app.js
View file @
b8a28b4
This diff is collapsed. Click to expand it.
Chatbot/package.json
View file @
b8a28b4
...
...
@@ -15,6 +15,7 @@
"cheerio"
:
"^1.0.0-rc.11"
,
"chromedriver"
:
"^101.0.0"
,
"express"
:
"^4.18.1"
,
"express-async-handler"
:
"^1.2.0"
,
"puppeteer"
:
"^14.1.1"
,
"selenium-webdriver"
:
"^4.1.2"
}
...
...
Please
register
or
login
to post a comment