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-05-28 18:32:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f443b9c267834ec567a16946de944f99ce9bfeaf
f443b9c2
1 parent
02fb1715
receiving usesr info and adding screening info
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
17 deletions
Megabox_crawling/app.js
Megabox_crawling/app.js
View file @
f443b9c
...
...
@@ -8,8 +8,15 @@ var By = webdriver.By;
const
chrome
=
require
(
'selenium-webdriver/chrome'
);
//크롬 사용시
const
async
=
require
(
'async'
)
let
express
=
require
(
'express'
);
let
app
=
express
();
let
bodyParser
=
require
(
'body-parser'
);
const
{
timeout
}
=
require
(
'async'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
let
booking_url
=
"https://megabox.co.kr/booking"
;
const
booking_url
=
"https://megabox.co.kr/booking"
;
const
rate_url
=
"https://www.megabox.co.kr/movie"
;
let
r
=
0
;
...
...
@@ -17,13 +24,13 @@ let movie_data = [];
let
location_data
=
[];
let
index
=
0
;
async
.
waterfall
([
async
()
=>
{
const
driver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
build
();
//.setChromeOptions(new chrome.Options().headless())
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'
)));
...
...
@@ -34,12 +41,15 @@ async.waterfall([
const
location_list
=
[
seoul
,
Gyeonggi
,
Incheon
,
DCS
,
BDG
,
GJ
,
Gangwon
]
//
for
(
let
i
=
0
;
i
<
location_list
.
length
;
i
++
){
for
(
item
of
location_list
[
i
])
{
let
location_name
=
await
item
.
getAttribute
(
"brch-nm"
);
let
location_num
=
await
item
.
getAttribute
(
"brch-no"
);
let
obj
=
{};
obj
[
location_name
]
=
location_num
console
.
log
(
obj
)
location_data
[
index
++
]
=
obj
;
location_data
[
index
++
]
=
{
'LocationName'
:
await
item
.
getAttribute
(
"brch-nm"
),
'LocationNUm'
:
await
item
.
getAttribute
(
"brch-no"
)
}
// let location_name = await item.getAttribute("brch-nm");
// let location_num = await item.getAttribute("brch-no");
// let obj = {};
// obj[location_name]= location_num
// location_data[index++] = obj;
}
}
...
...
@@ -52,7 +62,6 @@ async.waterfall([
'rank'
:
r
,
'title'
:
await
item
.
getAttribute
(
"movie-nm"
),
'movie_num'
:
await
item
.
getAttribute
(
"movie-no"
),
'running'
:
await
item
.
getAttribute
(
"form-at"
),
}
}
...
...
@@ -81,13 +90,56 @@ async.waterfall([
}
});
for
(
i
of
movie_data
){
if
(
Object
.
keys
(
i
).
length
==
4
){
if
(
Object
.
keys
(
i
).
length
==
3
){
movie_data
[
r
++
][
'rate'
]
=
'예매율 0%'
;
}
}
for
(
i
of
location_data
){
console
.
log
(
i
[
'동탄'
])
}
browser
.
close
();
}
},
])
let
userData
=
{
'Date'
:
''
,
'location'
:
''
};
// const _sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
app
.
get
(
'/Megabox'
,
(
req
,
res
)
=>
{
res
.
send
(
movie_data
);
})
const
appdriver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
//.setChromeOptions(new chrome.Options().headless())
app
.
post
(
'/Megabox'
,
(
req
,
res
)
=>
{
//사용자에게 Date와 location(영화관 장소) 받아옴
userData
[
'Date'
]
=
req
.
body
.
Date
;
for
(
i
of
location_data
){
if
(
i
[
'LocationName'
]
==
req
.
body
.
location
){
userData
[
'location'
]
=
i
[
'LocationNUm'
];
break
;
}
}
let
PlayingMovieURL
=
booking_url
+
'?brchNo1='
+
userData
[
'location'
]
+
'&playDe='
+
userData
[
'Date'
];
//사용자 정보 바탕으로 해당 일자 영화관 영화 상영 여부 확인
appdriver
.
get
(
PlayingMovieURL
);
appdriver
.
switchTo
().
frame
(
0
)
//frameBokdMBooking 프레임 가져옴
res
.
send
(
movie_data
);
})
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'
)
}
res
.
send
(
movie_data
);
})
app
.
listen
(
23023
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment