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-05 23:36:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9a0633c02de1d5f61c612051c98069c4c3972f56
9a0633c0
1 parent
8a17c25a
Solve some issues
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
25 deletions
WebCrawling/src/CGVExample.java
WebCrawling/src/CGVTicketing.js
WebCrawling/src/CGVExample.java
View file @
9a0633c
...
...
@@ -3,19 +3,19 @@ import org.jsoup.nodes.Document;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
import
java.awt.*
;
import
java.io.*
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.*
;
import
java.util.List
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeOptions
;
import
java.awt.*
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.List
;
import
java.util.*
;
class
CGVMovieInfo
{
//CGV 영화 정보를 담는 class
private
String
title
;
//영화 제목
private
int
rank
;
//CGV 내 예매율 순위
...
...
WebCrawling/src/CGVTicketing.js
View file @
9a0633c
...
...
@@ -17,7 +17,7 @@ const By = webdriver.By;
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
const
url_movies
=
"https://www.cgv.co.kr/movies/?lt=1&ft=
1
"
;
//끝의 쿼리 0은 개봉 전 영화도 포함하는 것. 예매율 순위 가져오기
const
url_movies
=
"https://www.cgv.co.kr/movies/?lt=1&ft=
0
"
;
//끝의 쿼리 0은 개봉 전 영화도 포함하는 것. 예매율 순위 가져오기
const
url_theaters
=
"https://www.cgv.co.kr/theaters"
;
//영화관 정보 가져오는 링크.
const
url_ticketing
=
"https://www.cgv.co.kr/ticket/"
;
//상영중인 영화 정보 가져오는 링크.
...
...
@@ -62,29 +62,42 @@ async.waterfall([
const
driver_theaters
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
driver_theaters
.
get
(
url_theaters
);
//영화관 및 영화관에 대응되는 영화관별 고유 코드 가져오기.
let
area
=
await
driver_theaters
.
wait
(
until
.
elementsLocated
(
By
.
className
(
"area"
)));
for
(
const
elem
of
area
)
{
let
theaters_info
=
new
Map
();
let
theaters_by_area
=
await
elem
.
wait
(
until
.
elementsLocated
(
By
.
tagName
(
'a'
)));
theaters_by_area
.
forEach
(
theater
=>
{
const
theater_name
=
theater
.
getAttribute
(
"title"
).
replace
(
"CGV"
,
""
);
const
theater_code
=
theater
.
getAttribute
(
"href"
).
replaceAll
(
"(.+(?<=theaterCode=))|(.+(?<=theatercode=))"
,
""
).
substring
(
0
,
4
);
theaters_info
.
set
(
theater_name
,
theater_code
);
});
cgv_theaters
.
push
(
theaters_info
);
let
selector
=
'#contents > div.sect-common > div > div.sect-city > ul > li:nth-child({}) > div > ul > li > a'
;
let
area
=
[];
for
(
let
i
=
1
;
i
<=
9
;
i
++
){
let
region
=
await
driver_theaters
.
wait
(
until
.
elementsLocated
(
By
.
css
(
selector
.
replace
(
"{}"
,
i
))));
area
.
push
(
region
);
}
let
n
=
0
;
for
(
const
theaters_by_area
of
area
)
{
let
theaters_info_by_area
=
[];
for
(
const
theater
of
theaters_by_area
){
let
theater_name
=
await
theater
.
getAttribute
(
'title'
);
let
theater_info
=
{
"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
);
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
()
);
const
driver_movies
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()
).
build
(
);
driver_movies
.
get
(
url_movies
);
//예매율 Top19까지의 영화의 정보를 가져옴.
cons
t
chart
=
await
driver_movies
.
wait
(
until
.
elementLocated
(
By
.
className
(
"sect-movie-chart"
)));
const
rank
=
await
chart
.
wait
(
until
.
elementsLocated
(
By
.
css
(
"strong.rank"
)
));
const
title
=
await
chart
.
wait
(
until
.
elementsLocated
(
By
.
css
(
"strong.title"
)
));
const
score
=
await
chart
.
wait
(
until
.
elementsLocated
(
By
.
css
(
"strong.percent"
)
));
const
GoldenEgg
=
await
chart
.
wait
(
until
.
elementsLocated
(
By
.
css
(
"span.percent"
)
));
const
link
=
await
chart
.
wait
(
until
.
elementsLocated
(
By
.
css
(
"a.plink-reservation"
)
));
le
t
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"
));
//영화 제목, 순위, 예매율, 영화 코드, 골든에그 지수를 가져와 CGVMovieInfo 객체 생성자에 파라미터로 넘겨주고, 인스턴스를 받아옴.
for
(
let
i
=
0
;
i
<
rank
.
length
;
i
++
)
{
...
...
@@ -95,5 +108,16 @@ async.waterfall([
const
newMovie
=
new
CGVMovieInfo
(
newTitle
,
newRank
,
newScore
,
GoldenEgg
[
i
],
newCode
);
cgv_movies
.
push
(
newMovie
);
}
driver_movies
.
close
();
}
]);
app
.
get
(
'/cgv_theaters'
,
(
req
,
res
)
=>
{
res
.
send
(
cgv_theaters
[
0
]);
});
app
.
post
(
''
,
(
req
,
res
)
=>
{
});
app
.
listen
(
23023
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment