Showing
1 changed file
with
18 additions
and
12 deletions
... | @@ -5,31 +5,27 @@ from selenium import webdriver | ... | @@ -5,31 +5,27 @@ from selenium import webdriver |
5 | from webdriver_manager.chrome import ChromeDriverManager | 5 | from webdriver_manager.chrome import ChromeDriverManager |
6 | from selenium.webdriver.common.keys import Keys | 6 | from selenium.webdriver.common.keys import Keys |
7 | 7 | ||
8 | - | ||
9 | options = webdriver.ChromeOptions() | 8 | options = webdriver.ChromeOptions() |
10 | options.add_argument("headless") #창 안 띄움 | 9 | options.add_argument("headless") #창 안 띄움 |
11 | options.add_experimental_option("excludeSwitches", ["enable-logging"]) | 10 | options.add_experimental_option("excludeSwitches", ["enable-logging"]) |
12 | driver = webdriver.Chrome(options = options) | 11 | driver = webdriver.Chrome(options = options) |
13 | driver2=webdriver.Chrome(options = options) | 12 | driver2=webdriver.Chrome(options = options) |
14 | -# driver = webdriver.Chrome(ChromeDriverManager().install(),options=options) | 13 | + |
15 | url = "https://megabox.co.kr/booking" | 14 | url = "https://megabox.co.kr/booking" |
16 | rate_url = "https://www.megabox.co.kr/movie" | 15 | rate_url = "https://www.megabox.co.kr/movie" |
17 | driver.maximize_window() | 16 | driver.maximize_window() |
18 | driver2.maximize_window() | 17 | driver2.maximize_window() |
19 | 18 | ||
20 | -driver.implicitly_wait(3) | 19 | +driver.implicitly_wait(2) |
21 | driver.get(url) | 20 | driver.get(url) |
22 | 21 | ||
23 | -driver2.implicitly_wait(3) | 22 | +driver2.implicitly_wait(2) |
24 | driver2.get(rate_url) | 23 | driver2.get(rate_url) |
25 | -title = driver2.find_elements_by_class_name('number') | 24 | + |
26 | r2 = driver2.page_source | 25 | r2 = driver2.page_source |
27 | soup = BeautifulSoup(r2, "html.parser") | 26 | soup = BeautifulSoup(r2, "html.parser") |
28 | ticketing_rate = soup.select('.rate') | 27 | ticketing_rate = soup.select('.rate') |
29 | -for i in ticketing_rate: | 28 | +movie_name = soup.select('.tit-area > p.tit') |
30 | - print(i.string) | ||
31 | - | ||
32 | - | ||
33 | 29 | ||
34 | iframes = driver.find_elements_by_css_selector('iframe') | 30 | iframes = driver.find_elements_by_css_selector('iframe') |
35 | 31 | ||
... | @@ -59,14 +55,24 @@ for brch in GJ: | ... | @@ -59,14 +55,24 @@ for brch in GJ: |
59 | dict1[brch['brch-nm']] = brch['brch-no'] | 55 | dict1[brch['brch-nm']] = brch['brch-no'] |
60 | for brch in Gangwon: | 56 | for brch in Gangwon: |
61 | dict1[brch['brch-nm']] = brch['brch-no'] | 57 | dict1[brch['brch-nm']] = brch['brch-no'] |
62 | -# print(dict1) | ||
63 | - | ||
64 | 58 | ||
65 | attr1 = soup.select("#mCSB_1_container>ul>li>button") | 59 | attr1 = soup.select("#mCSB_1_container>ul>li>button") |
60 | + | ||
66 | movie_dict = dict() | 61 | movie_dict = dict() |
67 | for movie in attr1: | 62 | for movie in attr1: |
68 | movie_dict[movie['movie-nm']] = [movie['movie-no'], movie['form-at']] | 63 | movie_dict[movie['movie-nm']] = [movie['movie-no'], movie['form-at']] |
69 | - print(movie['movie-nm'], movie['movie-no'], movie['form-at']) | 64 | + |
65 | +for r, m in zip(ticketing_rate, movie_name): | ||
66 | + movie_dict[m['title']].append(r.string) | ||
67 | + | ||
68 | +rank = 1 | ||
69 | +for value in movie_dict.values(): | ||
70 | + if(len(value) == 2): | ||
71 | + value.append("예메율 0.0%") | ||
72 | + if(rank<=10): | ||
73 | + value.append({'rank' : rank}) | ||
74 | + rank += 1 | ||
75 | +print(movie_dict) | ||
70 | 76 | ||
71 | #form-at: 처음 그냥 받아올 때 해당 날짜에 영화 있는지 확인(장소 상관 없이) | 77 | #form-at: 처음 그냥 받아올 때 해당 날짜에 영화 있는지 확인(장소 상관 없이) |
72 | #brch-no로 쿼리 주고 나서 form-at확인 필요 | 78 | #brch-no로 쿼리 주고 나서 form-at확인 필요 | ... | ... |
-
Please register or login to post a comment