Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ShinSeungMin
/
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
ShinSeungMin
2022-05-27 23:54:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
20234df2adc62597d9554734e9bd3eeb1276750d
20234df2
1 parent
88e379d9
Add getting playing movie information
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
20 deletions
LotteCinema/app.js
LotteCinema/app.js
View file @
20234df
...
...
@@ -8,9 +8,22 @@ const puppeteer = require('puppeteer');
const
cheerio
=
require
(
'cheerio'
);
const
{
textContent
}
=
require
(
'domutils'
);
//https://www.lottecinema.co.kr/NLCHS/Ticketing?movieCd=18632&movieName=범죄도시%202&screenCd=1|1|1009&screenName=김포공항&releaseDate=2022-05-18
let
movieData
=
[];
let
theaterData
=
[];
function
getToday
(){
var
date
=
new
Date
();
var
year
=
date
.
getFullYear
();
var
month
=
(
"0"
+
(
1
+
date
.
getMonth
())).
slice
(
-
2
);
var
day
=
(
"0"
+
date
.
getDate
()).
slice
(
-
2
);
return
year
+
"-"
+
month
+
"-"
+
day
;
}
//console.log(getToday());
app
.
get
(
'/LotteCinema'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
(
async
()
=>
{
const
browser
=
await
puppeteer
.
launch
();
const
page
=
await
browser
.
newPage
();
...
...
@@ -21,13 +34,13 @@ app.get('/LotteCinema', asyncHandler(async (req, res, next) => {
let
content
=
await
page
.
content
();
let
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
});
let
data
=
[];
const
$bodyList
=
$
(
"#contents > div > ul.movie_list.type2"
).
children
(
"li"
);
let
i
=
0
;
$bodyList
.
each
(
function
(
elem
){
$bodyList
.
each
(
function
(
temp_Body
){
if
(
$
(
this
).
find
(
'a > em'
).
text
()
!=
"AD"
){
d
ata
[
i
++
]
=
{
movieD
ata
[
i
++
]
=
{
rank
:
i
,
url
:
$
(
this
).
find
(
'div.top_info > div > div > a'
).
attr
(
'href'
),
title
:
$
(
this
).
find
(
' div.btm_info > strong'
).
text
(),
...
...
@@ -36,26 +49,14 @@ app.get('/LotteCinema', asyncHandler(async (req, res, next) => {
};
}
});
await
browser
.
close
();
res
.
send
(
data
);
//console.log(data);
}))
app
.
get
(
'/LotteCinema/theater'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
const
browser
=
await
puppeteer
.
launch
();
const
page
=
await
browser
.
newPage
();
// 수집하고자 하는 URL을 입력
await
page
.
goto
(
'https://www.lottecinema.co.kr/NLCHS/'
);
let
content
=
await
page
.
content
();
let
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
});
let
theaterData
=
[];
content
=
await
page
.
content
();
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
});
const
$TypeList
=
$
(
"#nav > ul > li:nth-child(3) > div > ul"
).
children
(
"li"
).
find
(
"div > ul"
).
children
(
"li"
);
let
i
=
0
;
i
=
0
;
let
flag
=
0
;
$TypeList
.
each
(
function
(
temp_Type
){
if
(
flag
==
1
){
...
...
@@ -71,10 +72,72 @@ app.get('/LotteCinema/theater', asyncHandler(async (req, res, next) => {
flag
++
;
}
});
await
browser
.
close
();
console
.
log
(
"Completed!"
);
})();
app
.
get
(
'/LotteCinema'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
res
.
send
(
movieData
);
//console.log(movieData);
}))
app
.
get
(
'/LotteCinema/theater'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
res
.
send
(
theaterData
);
//console.log(theaterData);
}))
app
.
get
(
'/LotteCinema/GetPlayingMovie'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
const
browser1
=
await
puppeteer
.
launch
();
const
page1
=
await
browser1
.
newPage
();
testTheaterName
=
"판교"
;
testDate
=
"2022-05-30"
let
PlayingMovieURL
;
let
playingMovieData
=
[];
theaterData
.
forEach
((
val
,
index
)
=>
{
// console.log(val);
if
(
val
.
LocateName
.
includes
(
testTheaterName
)){
PlayingMovieURL
=
movieData
[
0
].
url
+
"&screenCd="
+
val
.
LocateQuery
+
"&screenName="
+
val
.
LocateName
+
"&releaseDate="
+
testDate
;
}
})
//console.log(!PlayingMovieURL);
if
(
PlayingMovieURL
){
await
page1
.
goto
(
PlayingMovieURL
);
content
=
await
page1
.
content
();
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
});
let
i
=
0
;
const
$AbleList
=
$
(
"#mCSB_9_container > ul"
).
children
(
"li"
);
$AbleList
.
each
(
function
(
temp_Able
){
if
(
$
(
this
).
attr
(
"class"
)
!=
"disabled"
){
playingMovieData
[
i
++
]
=
{
rank
:
i
,
title
:
$
(
this
).
find
(
"a > div.group_infor > div > strong"
).
text
(),
}
}
});
}
else
{
res
.
send
(
"Please wait until get Movie and Theater information!"
);
console
.
log
(
"Please wait until get Movie and Theater information!"
);
}
await
browser1
.
close
();
res
.
send
(
playingMovieData
);
//console.log(theaterData);
}))
let
server
=
app
.
listen
(
80
);
...
...
Please
register
or
login
to post a comment