Showing
1 changed file
with
47 additions
and
23 deletions
1 | +from urllib import response | ||
1 | import requests | 2 | import requests |
2 | from bs4 import BeautifulSoup | 3 | from bs4 import BeautifulSoup |
3 | from selenium import webdriver | 4 | from selenium import webdriver |
4 | from webdriver_manager.chrome import ChromeDriverManager | 5 | from webdriver_manager.chrome import ChromeDriverManager |
5 | from selenium.webdriver.common.keys import Keys | 6 | from selenium.webdriver.common.keys import Keys |
6 | 7 | ||
7 | -# driver = webdriver.Chrome() | ||
8 | - | ||
9 | 8 | ||
10 | options = webdriver.ChromeOptions() | 9 | options = webdriver.ChromeOptions() |
10 | +options.add_argument("headless") #창 안 띄움 | ||
11 | options.add_experimental_option("excludeSwitches", ["enable-logging"]) | 11 | options.add_experimental_option("excludeSwitches", ["enable-logging"]) |
12 | driver = webdriver.Chrome(options = options) | 12 | driver = webdriver.Chrome(options = options) |
13 | +driver2=webdriver.Chrome(options = options) | ||
13 | # driver = webdriver.Chrome(ChromeDriverManager().install(),options=options) | 14 | # driver = webdriver.Chrome(ChromeDriverManager().install(),options=options) |
14 | url = "https://megabox.co.kr/booking" | 15 | url = "https://megabox.co.kr/booking" |
16 | +rate_url = "https://www.megabox.co.kr/movie" | ||
15 | driver.maximize_window() | 17 | driver.maximize_window() |
18 | +driver2.maximize_window() | ||
16 | 19 | ||
17 | driver.implicitly_wait(3) | 20 | driver.implicitly_wait(3) |
18 | driver.get(url) | 21 | driver.get(url) |
22 | + | ||
23 | +driver2.implicitly_wait(3) | ||
24 | +driver2.get(rate_url) | ||
25 | +title = driver2.find_elements_by_class_name('number') | ||
26 | +r2 = driver2.page_source | ||
27 | +soup = BeautifulSoup(r2, "html.parser") | ||
28 | +ticketing_rate = soup.select('.rate') | ||
29 | +for i in ticketing_rate: | ||
30 | + print(i.string) | ||
31 | + | ||
32 | + | ||
33 | + | ||
19 | iframes = driver.find_elements_by_css_selector('iframe') | 34 | iframes = driver.find_elements_by_css_selector('iframe') |
20 | 35 | ||
21 | driver.switch_to.frame('frameBokdMBooking') | 36 | driver.switch_to.frame('frameBokdMBooking') |
22 | -driver.find_element_by_id('btn') | ||
23 | r = driver.page_source | 37 | r = driver.page_source |
24 | soup = BeautifulSoup(r, "html.parser") | 38 | soup = BeautifulSoup(r, "html.parser") |
25 | 39 | ||
26 | -attr = soup.select("#mCSB_4_container>ul>li>button") | 40 | +seoul = soup.select("#mCSB_4_container>ul>li>button") |
27 | -for brch in attr: | 41 | +Gyeonggi = soup.select("#mCSB_5_container>ul>li>button") |
28 | - print(brch['brch-nm'], brch['brch-no']) | 42 | +Incheon = soup.select("#mCSB_6_container>ul>li>button") |
43 | +DCS = soup.select("#mCSB_7_container>ul>li>button")#Daejeon Chungcheong Sejong | ||
44 | +BDG = soup.select("#mCSB_8_container>ul>li>button")#Busan Daegu Gyeongsang | ||
45 | +GJ= soup.select("#mCSB_9_container>ul>li>button")#gwangju_jeonla | ||
46 | +Gangwon = soup.select("#mCSB_10_container>ul>li>button") | ||
47 | +dict1 = dict() | ||
48 | +for brch in seoul: | ||
49 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
50 | +for brch in Gyeonggi: | ||
51 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
52 | +for brch in Incheon: | ||
53 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
54 | +for brch in DCS: | ||
55 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
56 | +for brch in BDG: | ||
57 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
58 | +for brch in GJ: | ||
59 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
60 | +for brch in Gangwon: | ||
61 | + dict1[brch['brch-nm']] = brch['brch-no'] | ||
62 | +# print(dict1) | ||
63 | + | ||
29 | 64 | ||
30 | attr1 = soup.select("#mCSB_1_container>ul>li>button") | 65 | attr1 = soup.select("#mCSB_1_container>ul>li>button") |
66 | +movie_dict = dict() | ||
31 | for movie in attr1: | 67 | for movie in attr1: |
32 | - print(movie['movie-nm'], movie['movie-no']) | 68 | + movie_dict[movie['movie-nm']] = [movie['movie-no'], movie['form-at']] |
33 | - | 69 | + print(movie['movie-nm'], movie['movie-no'], movie['form-at']) |
34 | -# for i in btn: | 70 | + |
35 | -# print(i['brch-nm']) | 71 | +#form-at: 처음 그냥 받아올 때 해당 날짜에 영화 있는지 확인(장소 상관 없이) |
36 | -#driver.find_element_by_css_selector('div').send_keys(Keys.ENTER) | 72 | +#brch-no로 쿼리 주고 나서 form-at확인 필요 |
37 | - | ||
38 | -# soup = BeautifulSoup(driver.page_source, 'html.parser') | ||
39 | -# theater = soup.select('li') | ||
40 | - | ||
41 | -# for i in theater: | ||
42 | -# print(i.text) | ||
43 | -# driver.close() | ||
44 | -# response = requests.post(url) | ||
45 | -# soup = BeautifulSoup(response.text, "html.parser") | ||
46 | -# movie_location = {} | ||
47 | -# for(brch_nm) in soup.select('#frameBokdMBooking'): | ||
48 | -# print(brch_nm) | ... | ... |
-
Please register or login to post a comment