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
ShinSeungMin
2022-05-20 01:54:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3c080cbb74abdebecbf18a0fe8b456c95cdf2e45
3c080cbb
1 parent
a5914620
Add Crawling LotteCinema Theater Code
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
29 deletions
LotteCinema/app.js
LotteCinema/app.js
View file @
3c080cb
...
...
@@ -6,6 +6,7 @@ const { response } = require('express');
const
puppeteer
=
require
(
'puppeteer'
);
const
cheerio
=
require
(
'cheerio'
);
const
{
textContent
}
=
require
(
'domutils'
);
app
.
get
(
'/LotteCinema'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -28,7 +29,7 @@ app.get('/LotteCinema', asyncHandler(async (req, res, next) => {
if
(
$
(
this
).
find
(
'a > em'
).
text
()
!=
"AD"
){
data
[
i
++
]
=
{
rank
:
i
,
url
:
$
(
this
).
find
(
'div.top_info > div > div > a'
).
attr
(
'href'
)
.
replace
(
""
)
,
url
:
$
(
this
).
find
(
'div.top_info > div > div > a'
).
attr
(
'href'
),
title
:
$
(
this
).
find
(
' div.btm_info > strong'
).
text
(),
rate
:
$
(
this
).
find
(
'div.btm_info > span > span.rate_info > em'
).
text
(),
star
:
$
(
this
).
find
(
'div.btm_info > span > span.star_info'
).
text
(),
...
...
@@ -41,35 +42,39 @@ app.get('/LotteCinema', asyncHandler(async (req, res, next) => {
//console.log(data);
}))
let
server
=
app
.
listen
(
80
);
// (async () => {
// const browser = await puppeteer.launch();
// const page = await browser.newPage();
// // 수집하고자 하는 URL을 입력
// await page.goto('https://www.lottecinema.co.kr/NLCHS/Movie/List?flag=1');
app
.
get
(
'/LotteCinema/theater'
,
asyncHandler
(
async
(
req
,
res
,
next
)
=>
{
const
browser
=
await
puppeteer
.
launch
();
const
page
=
await
browser
.
newPage
();
// let content = await page.content();
// let $ = cheerio.load(content, {decodeEntities: true});
// let data = [];
// const $bodyList = $("#contents > div > ul.movie_list.type2").children("li");
// 수집하고자 하는 URL을 입력
await
page
.
goto
(
'https://www.lottecinema.co.kr/NLCHS/'
);
// let i =0;
// $bodyList.each(function(elem){
// if($(this).find('a > em').text() != "AD"){
// data[i++]={
// rank : i,
// url: $(this).find('div.top_info > div > div > a').attr('href').replace(""),
// title : $(this).find(' div.btm_info > strong').text(),
// rate : $(this).find('div.btm_info > span > span.rate_info > em').text(),
// star : $(this).find('div.btm_info > span > span.star_info').text(),
// };
// }
// });
// await browser.close();
let
content
=
await
page
.
content
();
let
$
=
cheerio
.
load
(
content
,
{
decodeEntities
:
true
});
let
theaterData
=
[];
const
$TypeList
=
$
(
"#nav > ul > li:nth-child(3) > div > ul"
).
children
(
"li"
).
find
(
"div > ul"
).
children
(
"li"
);
let
i
=
0
;
let
flag
=
0
;
$TypeList
.
each
(
function
(
temp_Type
){
if
(
flag
==
1
){
theaterData
[
i
++
]
=
{
LocateUrl
:
$
(
this
).
find
(
'a'
).
attr
(
'href'
),
LocateName
:
$
(
this
).
find
(
'a'
).
text
(),
LocateQuery
:
$
(
this
).
find
(
'a'
).
attr
(
'href'
)
.
replace
(
"https://www.lottecinema.co.kr/NLCHS/Cinema/Detail?divisionCode="
,
""
)
.
replace
(
"https://www.lottecinema.co.kr/NLCHS/Cinema/SpecialCinema?divisionCode="
,
""
)
.
replace
(
"&detailDivisionCode="
,
"|"
).
replace
(
"&cinemaID="
,
"|"
).
replace
(
"&screendivcd="
,
"|"
),
};
}
else
{
flag
++
;
}
});
await
browser
.
close
();
// console.log(data);
// })();
res
.
send
(
theaterData
);
//console.log(theaterData);
}))
let
server
=
app
.
listen
(
80
);
...
...
Please
register
or
login
to post a comment