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
임승현
2022-05-20 21:32:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1a725f8a8db8465d92bb7ba13f2255dd712d1840
1a725f8a
1 parent
ec9b3bde
Edit for Crawling CGV Theaters
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
WebCrawling/src/CGVExample.java
WebCrawling/src/CGVExample.java
View file @
1a725f8
...
...
@@ -82,21 +82,29 @@ class CGVMovieInfo { //CGV 영화 정보를 담는 class
public
class
CGVExample
{
public
static
void
main
(
String
[]
args
)
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
String
url
=
"https://www.cgv.co.kr/movies/?lt=1&ft=1"
;
//끝의 쿼리 0은 개봉 전 영화도 포함하는 것.
Document
doc
;
ArrayList
<
CGVMovieInfo
>
Movies
=
new
ArrayList
<>();
String
url_movies
=
"https://www.cgv.co.kr/movies/?lt=1&ft=1"
;
//끝의 쿼리 0은 개봉 전 영화도 포함하는 것. 예매율 순위 가져오기
String
url_theaters
=
"https://www.cgv.co.kr/theaters"
;
//영화관 정보 가져오기.
Document
doc_movies
,
doc_theaters
;
ArrayList
<
LinkedHashMap
<
String
,
Integer
>>
Theaters
=
new
ArrayList
<>();
//지역별 영화관 HashMap(Key: 영화관, value:영화관별 고유코드)으로 이루어진 Arraylist
ArrayList
<
CGVMovieInfo
>
Movies
=
new
ArrayList
<>();
//CGVMovieInfo 클래스의 인스턴스들을 원소로 가지는 Arraylist
try
{
doc
=
Jsoup
.
connect
(
url
).
get
();
//Top 19 까지
Elements
elements1
=
doc
.
select
(
"div.sect-movie-chart"
);
doc_movies
=
Jsoup
.
connect
(
url_movies
).
get
();
doc_theaters
=
Jsoup
.
connect
(
url_theaters
).
get
();
//예매율 Top19까지의 영화의 정보를 가져옴.
Elements
elements1
=
doc_movies
.
select
(
"div.sect-movie-chart"
);
Iterator
<
Element
>
rank
=
elements1
.
select
(
"strong.rank"
).
iterator
();
Iterator
<
Element
>
title
=
elements1
.
select
(
"strong.title"
).
iterator
();
Iterator
<
Element
>
score
=
elements1
.
select
(
"strong.percent"
).
iterator
();
Iterator
<
Element
>
GoldenEgg
=
elements1
.
select
(
"span.percent"
).
iterator
();
Iterator
<
Element
>
link
=
elements1
.
select
(
"a.link-reservation"
).
iterator
();
//Top 19 이후
//Elements elements2 = doc.select("div.sect-movie-chart");
//서울/경기/인천/강원/대전,충청/대구/부산,울산/경상/광주,전라,제주 - 광역 정보 가져오기
Elements
elements2
=
doc_theaters
.
getElementsByAttributeValue
(
"class"
,
"sect-city"
);
Iterator
<
Element
>
region
=
elements2
.
select
(
"li.on"
).
iterator
();
while
(
title
.
hasNext
()){
String
newTitle
=
title
.
next
().
text
();
...
...
@@ -107,13 +115,18 @@ public class CGVExample {
CGVMovieInfo
newMovie
=
new
CGVMovieInfo
(
newTitle
,
newRank
,
newScore
,
GoldenEgg
.
next
().
text
(),
newCode
);
Movies
.
add
(
newMovie
);
}
while
(
region
.
hasNext
()){
System
.
out
.
println
(
region
.
next
().
text
());
}
}
catch
(
IOException
e
){
e
.
printStackTrace
();
}
for
(
CGVMovieInfo
elem
:
Movies
)
{
elem
.
printMovieInfo
();
//
System.out.println(elem.getRank() + " : " + elem.getTitle());
//
elem.printMovieInfo();
System
.
out
.
println
(
elem
.
getRank
()
+
" : "
+
elem
.
getTitle
());
}
System
.
out
.
print
(
"예매하고 싶은 영화의 순위를 입력하세요 : "
);
...
...
Please
register
or
login
to post a comment